Skip to content

Commit 1dd8b1b

Browse files
Nirmoy Dasalexdeucher
authored andcommitted
drm/amdgpu: do not pass ttm_resource_manager to gtt_mgr
Do not allow exported amdgpu_gtt_mgr_*() to accept any ttm_resource_manager pointer. Also there is no need to force other module to call a ttm function just to eventually call gtt_mgr functions. v4: remove unused adev. v3: upcast mgr from ttm resopurce manager instead of getting it from adev. v2: pass adev's gtt_mgr instead of adev. Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 62d5f9f commit 1dd8b1b

4 files changed

Lines changed: 12 additions & 17 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4371,7 +4371,7 @@ static int amdgpu_device_reset_sriov(struct amdgpu_device *adev,
43714371

43724372
amdgpu_virt_init_data_exchange(adev);
43734373
/* we need recover gart prior to run SMC/CP/SDMA resume */
4374-
amdgpu_gtt_mgr_recover(ttm_manager_type(&adev->mman.bdev, TTM_PL_TT));
4374+
amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
43754375

43764376
r = amdgpu_device_fw_loading(adev);
43774377
if (r)
@@ -4691,7 +4691,7 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,
46914691
amdgpu_inc_vram_lost(tmp_adev);
46924692
}
46934693

4694-
r = amdgpu_gtt_mgr_recover(ttm_manager_type(&tmp_adev->mman.bdev, TTM_PL_TT));
4694+
r = amdgpu_gtt_mgr_recover(&tmp_adev->mman.gtt_mgr);
46954695
if (r)
46964696
goto out;
46974697

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,8 @@ static ssize_t amdgpu_mem_info_gtt_used_show(struct device *dev,
7777
{
7878
struct drm_device *ddev = dev_get_drvdata(dev);
7979
struct amdgpu_device *adev = drm_to_adev(ddev);
80-
struct ttm_resource_manager *man;
8180

82-
man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
83-
return sysfs_emit(buf, "%llu\n", amdgpu_gtt_mgr_usage(man));
81+
return sysfs_emit(buf, "%llu\n", amdgpu_gtt_mgr_usage(&adev->mman.gtt_mgr));
8482
}
8583

8684
static DEVICE_ATTR(mem_info_gtt_total, S_IRUGO,
@@ -206,30 +204,27 @@ static void amdgpu_gtt_mgr_del(struct ttm_resource_manager *man,
206204
/**
207205
* amdgpu_gtt_mgr_usage - return usage of GTT domain
208206
*
209-
* @man: TTM memory type manager
207+
* @mgr: amdgpu_gtt_mgr pointer
210208
*
211209
* Return how many bytes are used in the GTT domain
212210
*/
213-
uint64_t amdgpu_gtt_mgr_usage(struct ttm_resource_manager *man)
211+
uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr)
214212
{
215-
struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
216-
217213
return atomic64_read(&mgr->used) * PAGE_SIZE;
218214
}
219215

220216
/**
221217
* amdgpu_gtt_mgr_recover - re-init gart
222218
*
223-
* @man: TTM memory type manager
219+
* @mgr: amdgpu_gtt_mgr pointer
224220
*
225221
* Re-init the gart for each known BO in the GTT.
226222
*/
227-
int amdgpu_gtt_mgr_recover(struct ttm_resource_manager *man)
223+
int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
228224
{
229-
struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
230-
struct amdgpu_device *adev;
231225
struct amdgpu_gtt_node *node;
232226
struct drm_mm_node *mm_node;
227+
struct amdgpu_device *adev;
233228
int r = 0;
234229

235230
adev = container_of(mgr, typeof(*adev), mman.gtt_mgr);

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
678678
ui64 = amdgpu_vram_mgr_vis_usage(ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM));
679679
return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0;
680680
case AMDGPU_INFO_GTT_USAGE:
681-
ui64 = amdgpu_gtt_mgr_usage(ttm_manager_type(&adev->mman.bdev, TTM_PL_TT));
681+
ui64 = amdgpu_gtt_mgr_usage(&adev->mman.gtt_mgr);
682682
return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0;
683683
case AMDGPU_INFO_GDS_CONFIG: {
684684
struct drm_amdgpu_info_gds gds_info;
@@ -738,7 +738,7 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
738738
mem.gtt.usable_heap_size = mem.gtt.total_heap_size -
739739
atomic64_read(&adev->gart_pin_size);
740740
mem.gtt.heap_usage =
741-
amdgpu_gtt_mgr_usage(gtt_man);
741+
amdgpu_gtt_mgr_usage(&adev->mman.gtt_mgr);
742742
mem.gtt.max_allocation = mem.gtt.usable_heap_size * 3 / 4;
743743

744744
return copy_to_user(out, &mem,

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev);
114114
void amdgpu_vram_mgr_fini(struct amdgpu_device *adev);
115115

116116
bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *mem);
117-
uint64_t amdgpu_gtt_mgr_usage(struct ttm_resource_manager *man);
118-
int amdgpu_gtt_mgr_recover(struct ttm_resource_manager *man);
117+
uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr);
118+
int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);
119119

120120
uint64_t amdgpu_preempt_mgr_usage(struct ttm_resource_manager *man);
121121

0 commit comments

Comments
 (0)