Skip to content

Commit fbac3c4

Browse files
committed
Merge branch 'drm-next-5.1' of git://people.freedesktop.org/~agd5f/linux into drm-next
Fixes for 5.1: amdgpu: - Fix missing fw declaration after dropping old CI DPM code - Fix debugfs access to registers beyond the MMIO bar size - Fix context priority handling - Add missing license on some new files - Various cleanups and bug fixes radeon: - Fix missing break in CS parser for evergreen - Various cleanups and bug fixes sched: - Fix entities with 0 run queues Signed-off-by: Dave Airlie <[email protected]> From: Alex Deucher <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents a5f2faf + 767e06a commit fbac3c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+701
-612
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,8 @@ struct amdgpu_fpriv {
411411
struct amdgpu_ctx_mgr ctx_mgr;
412412
};
413413

414+
int amdgpu_file_to_fpriv(struct file *filp, struct amdgpu_fpriv **fpriv);
415+
414416
int amdgpu_ib_get(struct amdgpu_device *adev, struct amdgpu_vm *vm,
415417
unsigned size, struct amdgpu_ib *ib);
416418
void amdgpu_ib_free(struct amdgpu_device *adev, struct amdgpu_ib *ib,

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

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static void amdgpu_doorbell_get_kfd_info(struct amdgpu_device *adev,
131131

132132
void amdgpu_amdkfd_device_init(struct amdgpu_device *adev)
133133
{
134-
int i, n;
134+
int i;
135135
int last_valid_bit;
136136

137137
if (adev->kfd.dev) {
@@ -142,7 +142,9 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev)
142142
.gpuvm_size = min(adev->vm_manager.max_pfn
143143
<< AMDGPU_GPU_PAGE_SHIFT,
144144
AMDGPU_GMC_HOLE_START),
145-
.drm_render_minor = adev->ddev->render->index
145+
.drm_render_minor = adev->ddev->render->index,
146+
.sdma_doorbell_idx = adev->doorbell_index.sdma_engine,
147+
146148
};
147149

148150
/* this is going to have a few of the MSBs set that we need to
@@ -172,35 +174,20 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev)
172174
&gpu_resources.doorbell_aperture_size,
173175
&gpu_resources.doorbell_start_offset);
174176

175-
if (adev->asic_type < CHIP_VEGA10) {
176-
kgd2kfd_device_init(adev->kfd.dev, &gpu_resources);
177-
return;
178-
}
179-
180-
n = (adev->asic_type < CHIP_VEGA20) ? 2 : 8;
181-
182-
for (i = 0; i < n; i += 2) {
183-
/* On SOC15 the BIF is involved in routing
184-
* doorbells using the low 12 bits of the
185-
* address. Communicate the assignments to
186-
* KFD. KFD uses two doorbell pages per
187-
* process in case of 64-bit doorbells so we
188-
* can use each doorbell assignment twice.
189-
*/
190-
gpu_resources.sdma_doorbell[0][i] =
191-
adev->doorbell_index.sdma_engine[0] + (i >> 1);
192-
gpu_resources.sdma_doorbell[0][i+1] =
193-
adev->doorbell_index.sdma_engine[0] + 0x200 + (i >> 1);
194-
gpu_resources.sdma_doorbell[1][i] =
195-
adev->doorbell_index.sdma_engine[1] + (i >> 1);
196-
gpu_resources.sdma_doorbell[1][i+1] =
197-
adev->doorbell_index.sdma_engine[1] + 0x200 + (i >> 1);
198-
}
199-
/* Doorbells 0x0e0-0ff and 0x2e0-2ff are reserved for
200-
* SDMA, IH and VCN. So don't use them for the CP.
177+
/* Since SOC15, BIF starts to statically use the
178+
* lower 12 bits of doorbell addresses for routing
179+
* based on settings in registers like
180+
* SDMA0_DOORBELL_RANGE etc..
181+
* In order to route a doorbell to CP engine, the lower
182+
* 12 bits of its address has to be outside the range
183+
* set for SDMA, VCN, and IH blocks.
201184
*/
202-
gpu_resources.reserved_doorbell_mask = 0x1e0;
203-
gpu_resources.reserved_doorbell_val = 0x0e0;
185+
if (adev->asic_type >= CHIP_VEGA10) {
186+
gpu_resources.non_cp_doorbells_start =
187+
adev->doorbell_index.first_non_cp;
188+
gpu_resources.non_cp_doorbells_end =
189+
adev->doorbell_index.last_non_cp;
190+
}
204191

205192
kgd2kfd_device_init(adev->kfd.dev, &gpu_resources);
206193
}

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

Lines changed: 13 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -204,38 +204,25 @@ void amdgpu_amdkfd_unreserve_memory_limit(struct amdgpu_bo *bo)
204204
}
205205

206206

207-
/* amdgpu_amdkfd_remove_eviction_fence - Removes eviction fence(s) from BO's
207+
/* amdgpu_amdkfd_remove_eviction_fence - Removes eviction fence from BO's
208208
* reservation object.
209209
*
210210
* @bo: [IN] Remove eviction fence(s) from this BO
211-
* @ef: [IN] If ef is specified, then this eviction fence is removed if it
211+
* @ef: [IN] This eviction fence is removed if it
212212
* is present in the shared list.
213-
* @ef_list: [OUT] Returns list of eviction fences. These fences are removed
214-
* from BO's reservation object shared list.
215-
* @ef_count: [OUT] Number of fences in ef_list.
216213
*
217-
* NOTE: If called with ef_list, then amdgpu_amdkfd_add_eviction_fence must be
218-
* called to restore the eviction fences and to avoid memory leak. This is
219-
* useful for shared BOs.
220214
* NOTE: Must be called with BO reserved i.e. bo->tbo.resv->lock held.
221215
*/
222216
static int amdgpu_amdkfd_remove_eviction_fence(struct amdgpu_bo *bo,
223-
struct amdgpu_amdkfd_fence *ef,
224-
struct amdgpu_amdkfd_fence ***ef_list,
225-
unsigned int *ef_count)
217+
struct amdgpu_amdkfd_fence *ef)
226218
{
227219
struct reservation_object *resv = bo->tbo.resv;
228220
struct reservation_object_list *old, *new;
229221
unsigned int i, j, k;
230222

231-
if (!ef && !ef_list)
223+
if (!ef)
232224
return -EINVAL;
233225

234-
if (ef_list) {
235-
*ef_list = NULL;
236-
*ef_count = 0;
237-
}
238-
239226
old = reservation_object_get_list(resv);
240227
if (!old)
241228
return 0;
@@ -254,30 +241,14 @@ static int amdgpu_amdkfd_remove_eviction_fence(struct amdgpu_bo *bo,
254241
f = rcu_dereference_protected(old->shared[i],
255242
reservation_object_held(resv));
256243

257-
if ((ef && f->context == ef->base.context) ||
258-
(!ef && to_amdgpu_amdkfd_fence(f)))
244+
if (f->context == ef->base.context)
259245
RCU_INIT_POINTER(new->shared[--j], f);
260246
else
261247
RCU_INIT_POINTER(new->shared[k++], f);
262248
}
263249
new->shared_max = old->shared_max;
264250
new->shared_count = k;
265251

266-
if (!ef) {
267-
unsigned int count = old->shared_count - j;
268-
269-
/* Alloc memory for count number of eviction fence pointers.
270-
* Fill the ef_list array and ef_count
271-
*/
272-
*ef_list = kcalloc(count, sizeof(**ef_list), GFP_KERNEL);
273-
*ef_count = count;
274-
275-
if (!*ef_list) {
276-
kfree(new);
277-
return -ENOMEM;
278-
}
279-
}
280-
281252
/* Install the new fence list, seqcount provides the barriers */
282253
preempt_disable();
283254
write_seqcount_begin(&resv->seq);
@@ -291,46 +262,13 @@ static int amdgpu_amdkfd_remove_eviction_fence(struct amdgpu_bo *bo,
291262

292263
f = rcu_dereference_protected(new->shared[i],
293264
reservation_object_held(resv));
294-
if (!ef)
295-
(*ef_list)[k++] = to_amdgpu_amdkfd_fence(f);
296-
else
297-
dma_fence_put(f);
265+
dma_fence_put(f);
298266
}
299267
kfree_rcu(old, rcu);
300268

301269
return 0;
302270
}
303271

304-
/* amdgpu_amdkfd_add_eviction_fence - Adds eviction fence(s) back into BO's
305-
* reservation object.
306-
*
307-
* @bo: [IN] Add eviction fences to this BO
308-
* @ef_list: [IN] List of eviction fences to be added
309-
* @ef_count: [IN] Number of fences in ef_list.
310-
*
311-
* NOTE: Must call amdgpu_amdkfd_remove_eviction_fence before calling this
312-
* function.
313-
*/
314-
static void amdgpu_amdkfd_add_eviction_fence(struct amdgpu_bo *bo,
315-
struct amdgpu_amdkfd_fence **ef_list,
316-
unsigned int ef_count)
317-
{
318-
int i;
319-
320-
if (!ef_list || !ef_count)
321-
return;
322-
323-
for (i = 0; i < ef_count; i++) {
324-
amdgpu_bo_fence(bo, &ef_list[i]->base, true);
325-
/* Re-adding the fence takes an additional reference. Drop that
326-
* reference.
327-
*/
328-
dma_fence_put(&ef_list[i]->base);
329-
}
330-
331-
kfree(ef_list);
332-
}
333-
334272
static int amdgpu_amdkfd_bo_validate(struct amdgpu_bo *bo, uint32_t domain,
335273
bool wait)
336274
{
@@ -346,18 +284,8 @@ static int amdgpu_amdkfd_bo_validate(struct amdgpu_bo *bo, uint32_t domain,
346284
ret = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
347285
if (ret)
348286
goto validate_fail;
349-
if (wait) {
350-
struct amdgpu_amdkfd_fence **ef_list;
351-
unsigned int ef_count;
352-
353-
ret = amdgpu_amdkfd_remove_eviction_fence(bo, NULL, &ef_list,
354-
&ef_count);
355-
if (ret)
356-
goto validate_fail;
357-
358-
ttm_bo_wait(&bo->tbo, false, false);
359-
amdgpu_amdkfd_add_eviction_fence(bo, ef_list, ef_count);
360-
}
287+
if (wait)
288+
amdgpu_bo_sync_wait(bo, AMDGPU_FENCE_OWNER_KFD, false);
361289

362290
validate_fail:
363291
return ret;
@@ -444,7 +372,6 @@ static int add_bo_to_vm(struct amdgpu_device *adev, struct kgd_mem *mem,
444372
{
445373
int ret;
446374
struct kfd_bo_va_list *bo_va_entry;
447-
struct amdgpu_bo *pd = vm->root.base.bo;
448375
struct amdgpu_bo *bo = mem->bo;
449376
uint64_t va = mem->va;
450377
struct list_head *list_bo_va = &mem->bo_va_list;
@@ -484,14 +411,8 @@ static int add_bo_to_vm(struct amdgpu_device *adev, struct kgd_mem *mem,
484411
*p_bo_va_entry = bo_va_entry;
485412

486413
/* Allocate new page tables if needed and validate
487-
* them. Clearing of new page tables and validate need to wait
488-
* on move fences. We don't want that to trigger the eviction
489-
* fence, so remove it temporarily.
414+
* them.
490415
*/
491-
amdgpu_amdkfd_remove_eviction_fence(pd,
492-
vm->process_info->eviction_fence,
493-
NULL, NULL);
494-
495416
ret = amdgpu_vm_alloc_pts(adev, vm, va, amdgpu_bo_size(bo));
496417
if (ret) {
497418
pr_err("Failed to allocate pts, err=%d\n", ret);
@@ -504,13 +425,9 @@ static int add_bo_to_vm(struct amdgpu_device *adev, struct kgd_mem *mem,
504425
goto err_alloc_pts;
505426
}
506427

507-
/* Add the eviction fence back */
508-
amdgpu_bo_fence(pd, &vm->process_info->eviction_fence->base, true);
509-
510428
return 0;
511429

512430
err_alloc_pts:
513-
amdgpu_bo_fence(pd, &vm->process_info->eviction_fence->base, true);
514431
amdgpu_vm_bo_rmv(adev, bo_va_entry->bo_va);
515432
list_del(&bo_va_entry->bo_list);
516433
err_vmadd:
@@ -809,24 +726,11 @@ static int unmap_bo_from_gpuvm(struct amdgpu_device *adev,
809726
{
810727
struct amdgpu_bo_va *bo_va = entry->bo_va;
811728
struct amdgpu_vm *vm = bo_va->base.vm;
812-
struct amdgpu_bo *pd = vm->root.base.bo;
813729

814-
/* Remove eviction fence from PD (and thereby from PTs too as
815-
* they share the resv. object). Otherwise during PT update
816-
* job (see amdgpu_vm_bo_update_mapping), eviction fence would
817-
* get added to job->sync object and job execution would
818-
* trigger the eviction fence.
819-
*/
820-
amdgpu_amdkfd_remove_eviction_fence(pd,
821-
vm->process_info->eviction_fence,
822-
NULL, NULL);
823730
amdgpu_vm_bo_unmap(adev, bo_va, entry->va);
824731

825732
amdgpu_vm_clear_freed(adev, vm, &bo_va->last_pt_update);
826733

827-
/* Add the eviction fence back */
828-
amdgpu_bo_fence(pd, &vm->process_info->eviction_fence->base, true);
829-
830734
amdgpu_sync_fence(NULL, sync, bo_va->last_pt_update, false);
831735

832736
return 0;
@@ -1002,7 +906,7 @@ static int init_kfd_vm(struct amdgpu_vm *vm, void **process_info,
1002906
pr_err("validate_pt_pd_bos() failed\n");
1003907
goto validate_pd_fail;
1004908
}
1005-
ret = ttm_bo_wait(&vm->root.base.bo->tbo, false, false);
909+
amdgpu_bo_sync_wait(vm->root.base.bo, AMDGPU_FENCE_OWNER_KFD, false);
1006910
if (ret)
1007911
goto wait_pd_fail;
1008912
amdgpu_bo_fence(vm->root.base.bo,
@@ -1389,8 +1293,7 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
13891293
* attached
13901294
*/
13911295
amdgpu_amdkfd_remove_eviction_fence(mem->bo,
1392-
process_info->eviction_fence,
1393-
NULL, NULL);
1296+
process_info->eviction_fence);
13941297
pr_debug("Release VA 0x%llx - 0x%llx\n", mem->va,
13951298
mem->va + bo_size * (1 + mem->aql_queue));
13961299

@@ -1617,8 +1520,7 @@ int amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(
16171520
if (mem->mapped_to_gpu_memory == 0 &&
16181521
!amdgpu_ttm_tt_get_usermm(mem->bo->tbo.ttm) && !mem->bo->pin_count)
16191522
amdgpu_amdkfd_remove_eviction_fence(mem->bo,
1620-
process_info->eviction_fence,
1621-
NULL, NULL);
1523+
process_info->eviction_fence);
16221524

16231525
unreserve_out:
16241526
unreserve_bo_and_vms(&ctx, false, false);
@@ -1679,7 +1581,7 @@ int amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel(struct kgd_dev *kgd,
16791581
}
16801582

16811583
amdgpu_amdkfd_remove_eviction_fence(
1682-
bo, mem->process_info->eviction_fence, NULL, NULL);
1584+
bo, mem->process_info->eviction_fence);
16831585
list_del_init(&mem->validate_list.head);
16841586

16851587
if (size)
@@ -1945,16 +1847,6 @@ static int validate_invalid_user_pages(struct amdkfd_process_info *process_info)
19451847

19461848
amdgpu_sync_create(&sync);
19471849

1948-
/* Avoid triggering eviction fences when unmapping invalid
1949-
* userptr BOs (waits for all fences, doesn't use
1950-
* FENCE_OWNER_VM)
1951-
*/
1952-
list_for_each_entry(peer_vm, &process_info->vm_list_head,
1953-
vm_list_node)
1954-
amdgpu_amdkfd_remove_eviction_fence(peer_vm->root.base.bo,
1955-
process_info->eviction_fence,
1956-
NULL, NULL);
1957-
19581850
ret = process_validate_vms(process_info);
19591851
if (ret)
19601852
goto unreserve_out;
@@ -2015,10 +1907,6 @@ static int validate_invalid_user_pages(struct amdkfd_process_info *process_info)
20151907
ret = process_update_pds(process_info, &sync);
20161908

20171909
unreserve_out:
2018-
list_for_each_entry(peer_vm, &process_info->vm_list_head,
2019-
vm_list_node)
2020-
amdgpu_bo_fence(peer_vm->root.base.bo,
2021-
&process_info->eviction_fence->base, true);
20221910
ttm_eu_backoff_reservation(&ticket, &resv_list);
20231911
amdgpu_sync_wait(&sync, false);
20241912
amdgpu_sync_free(&sync);

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev,
124124
struct amdgpu_ring *rings[AMDGPU_MAX_RINGS];
125125
struct drm_sched_rq *rqs[AMDGPU_MAX_RINGS];
126126
unsigned num_rings;
127+
unsigned num_rqs = 0;
127128

128129
switch (i) {
129130
case AMDGPU_HW_IP_GFX:
@@ -166,12 +167,16 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev,
166167
break;
167168
}
168169

169-
for (j = 0; j < num_rings; ++j)
170-
rqs[j] = &rings[j]->sched.sched_rq[priority];
170+
for (j = 0; j < num_rings; ++j) {
171+
if (!rings[j]->adev)
172+
continue;
173+
174+
rqs[num_rqs++] = &rings[j]->sched.sched_rq[priority];
175+
}
171176

172177
for (j = 0; j < amdgpu_ctx_num_entities[i]; ++j)
173178
r = drm_sched_entity_init(&ctx->entities[i][j].entity,
174-
rqs, num_rings, &ctx->guilty);
179+
rqs, num_rqs, &ctx->guilty);
175180
if (r)
176181
goto error_cleanup_entities;
177182
}

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,6 @@ static int amdgpu_debugfs_process_reg_op(bool read, struct file *f,
158158
while (size) {
159159
uint32_t value;
160160

161-
if (*pos > adev->rmmio_size)
162-
goto end;
163-
164161
if (read) {
165162
value = RREG32(*pos >> 2);
166163
r = put_user(value, (uint32_t *)buf);

0 commit comments

Comments
 (0)