Skip to content

Commit 0530553

Browse files
Le Maalexdeucher
authored andcommitted
drm/amdgpu: move vmhub out of amdgpu_ring_funcs (v4)
It looks better to place this field in ring structure. Also drop the repeated ring funcs definitions if there's no difference except for vmhub field. v2: rename the field to vm_hub like others (Le) v3: apply the changes to new ip blocks (Hawking) v4: fix vcn sw ring (Alex) Signed-off-by: Le Ma <[email protected]> Reviewed-by: Christian König <[email protected]> Reviewed-by: Hawking Zhang <[email protected]> Signed-off-by: Hawking Zhang <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent b805d8d commit 0530553

31 files changed

+93
-220
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ int amdgpu_gfx_kiq_init_ring(struct amdgpu_device *adev,
305305
ring->ring_obj = NULL;
306306
ring->use_doorbell = true;
307307
ring->doorbell_index = adev->doorbell_index.kiq;
308+
ring->vm_hub = AMDGPU_GFXHUB_0;
308309

309310
r = amdgpu_gfx_kiq_acquire(adev, ring);
310311
if (r)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ int amdgpu_gmc_allocate_vm_inv_eng(struct amdgpu_device *adev)
554554

555555
for (i = 0; i < adev->num_rings; ++i) {
556556
ring = adev->rings[i];
557-
vmhub = ring->funcs->vmhub;
557+
vmhub = ring->vm_hub;
558558

559559
if (ring == &adev->mes.ring)
560560
continue;
@@ -570,7 +570,7 @@ int amdgpu_gmc_allocate_vm_inv_eng(struct amdgpu_device *adev)
570570
vm_inv_engs[vmhub] &= ~(1 << ring->vm_inv_eng);
571571

572572
dev_info(adev->dev, "ring %s uses VM inv eng %u on hub %u\n",
573-
ring->name, ring->vm_inv_eng, ring->funcs->vmhub);
573+
ring->name, ring->vm_inv_eng, ring->vm_hub);
574574
}
575575

576576
return 0;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
267267
if (r) {
268268
dev_err(adev->dev, "failed to emit fence (%d)\n", r);
269269
if (job && job->vmid)
270-
amdgpu_vmid_reset(adev, ring->funcs->vmhub, job->vmid);
270+
amdgpu_vmid_reset(adev, ring->vm_hub, job->vmid);
271271
amdgpu_ring_undo(ring);
272272
return r;
273273
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ static int amdgpu_vmid_grab_idle(struct amdgpu_vm *vm,
202202
struct dma_fence **fence)
203203
{
204204
struct amdgpu_device *adev = ring->adev;
205-
unsigned vmhub = ring->funcs->vmhub;
205+
unsigned vmhub = ring->vm_hub;
206206
struct amdgpu_vmid_mgr *id_mgr = &adev->vm_manager.id_mgr[vmhub];
207207
struct dma_fence **fences;
208208
unsigned i;
@@ -277,7 +277,7 @@ static int amdgpu_vmid_grab_reserved(struct amdgpu_vm *vm,
277277
struct dma_fence **fence)
278278
{
279279
struct amdgpu_device *adev = ring->adev;
280-
unsigned vmhub = ring->funcs->vmhub;
280+
unsigned vmhub = ring->vm_hub;
281281
struct amdgpu_vmid_mgr *id_mgr = &adev->vm_manager.id_mgr[vmhub];
282282
uint64_t fence_context = adev->fence_context + ring->idx;
283283
bool needs_flush = vm->use_cpu_for_update;
@@ -338,7 +338,7 @@ static int amdgpu_vmid_grab_used(struct amdgpu_vm *vm,
338338
struct dma_fence **fence)
339339
{
340340
struct amdgpu_device *adev = ring->adev;
341-
unsigned vmhub = ring->funcs->vmhub;
341+
unsigned vmhub = ring->vm_hub;
342342
struct amdgpu_vmid_mgr *id_mgr = &adev->vm_manager.id_mgr[vmhub];
343343
uint64_t fence_context = adev->fence_context + ring->idx;
344344
uint64_t updates = amdgpu_vm_tlb_seq(vm);
@@ -398,7 +398,7 @@ int amdgpu_vmid_grab(struct amdgpu_vm *vm, struct amdgpu_ring *ring,
398398
struct amdgpu_job *job, struct dma_fence **fence)
399399
{
400400
struct amdgpu_device *adev = ring->adev;
401-
unsigned vmhub = ring->funcs->vmhub;
401+
unsigned vmhub = ring->vm_hub;
402402
struct amdgpu_vmid_mgr *id_mgr = &adev->vm_manager.id_mgr[vmhub];
403403
struct amdgpu_vmid *idle = NULL;
404404
struct amdgpu_vmid *id = NULL;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ struct amdgpu_ring_funcs {
165165
bool support_64bit_ptrs;
166166
bool no_user_fence;
167167
bool secure_submission_supported;
168-
unsigned vmhub;
169168
unsigned extra_dw;
170169

171170
/* ring read/write ptr handling */
@@ -275,6 +274,7 @@ struct amdgpu_ring {
275274
unsigned cond_exe_offs;
276275
u64 cond_exe_gpu_addr;
277276
volatile u32 *cond_exe_cpu_addr;
277+
unsigned vm_hub;
278278
unsigned vm_inv_eng;
279279
struct dma_fence *vmid_wait;
280280
bool has_compute_vm_bug;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ TRACE_EVENT(amdgpu_vm_grab_id,
233233
__entry->pasid = vm->pasid;
234234
__assign_str(ring, ring->name);
235235
__entry->vmid = job->vmid;
236-
__entry->vm_hub = ring->funcs->vmhub,
236+
__entry->vm_hub = ring->vm_hub,
237237
__entry->pd_addr = job->vm_pd_addr;
238238
__entry->needs_flush = job->vm_needs_flush;
239239
),
@@ -427,7 +427,7 @@ TRACE_EVENT(amdgpu_vm_flush,
427427
TP_fast_assign(
428428
__assign_str(ring, ring->name);
429429
__entry->vmid = vmid;
430-
__entry->vm_hub = ring->funcs->vmhub;
430+
__entry->vm_hub = ring->vm_hub;
431431
__entry->pd_addr = pd_addr;
432432
),
433433
TP_printk("ring=%s, id=%u, hub=%u, pd_addr=%010Lx",

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,
483483
struct amdgpu_job *job)
484484
{
485485
struct amdgpu_device *adev = ring->adev;
486-
unsigned vmhub = ring->funcs->vmhub;
486+
unsigned vmhub = ring->vm_hub;
487487
struct amdgpu_vmid_mgr *id_mgr = &adev->vm_manager.id_mgr[vmhub];
488488

489489
if (job->vmid == 0)
@@ -517,7 +517,7 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,
517517
bool need_pipe_sync)
518518
{
519519
struct amdgpu_device *adev = ring->adev;
520-
unsigned vmhub = ring->funcs->vmhub;
520+
unsigned vmhub = ring->vm_hub;
521521
struct amdgpu_vmid_mgr *id_mgr = &adev->vm_manager.id_mgr[vmhub];
522522
struct amdgpu_vmid *id = &id_mgr->ids[job->vmid];
523523
bool spm_update_needed = job->spm_update_needed;

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4461,6 +4461,7 @@ static int gfx_v10_0_gfx_ring_init(struct amdgpu_device *adev, int ring_id,
44614461
ring->doorbell_index = adev->doorbell_index.gfx_ring0 << 1;
44624462
else
44634463
ring->doorbell_index = adev->doorbell_index.gfx_ring1 << 1;
4464+
ring->vm_hub = AMDGPU_GFXHUB_0;
44644465
sprintf(ring->name, "gfx_%d.%d.%d", ring->me, ring->pipe, ring->queue);
44654466

44664467
irq_type = AMDGPU_CP_IRQ_GFX_ME0_PIPE0_EOP + ring->pipe;
@@ -4489,6 +4490,7 @@ static int gfx_v10_0_compute_ring_init(struct amdgpu_device *adev, int ring_id,
44894490
ring->doorbell_index = (adev->doorbell_index.mec_ring0 + ring_id) << 1;
44904491
ring->eop_gpu_addr = adev->gfx.mec.hpd_eop_gpu_addr
44914492
+ (ring_id * GFX10_MEC_HPD_SIZE);
4493+
ring->vm_hub = AMDGPU_GFXHUB_0;
44924494
sprintf(ring->name, "comp_%d.%d.%d", ring->me, ring->pipe, ring->queue);
44934495

44944496
irq_type = AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP
@@ -9249,7 +9251,6 @@ static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_gfx = {
92499251
.nop = PACKET3(PACKET3_NOP, 0x3FFF),
92509252
.support_64bit_ptrs = true,
92519253
.secure_submission_supported = true,
9252-
.vmhub = AMDGPU_GFXHUB_0,
92539254
.get_rptr = gfx_v10_0_ring_get_rptr_gfx,
92549255
.get_wptr = gfx_v10_0_ring_get_wptr_gfx,
92559256
.set_wptr = gfx_v10_0_ring_set_wptr_gfx,
@@ -9304,7 +9305,6 @@ static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_compute = {
93049305
.align_mask = 0xff,
93059306
.nop = PACKET3(PACKET3_NOP, 0x3FFF),
93069307
.support_64bit_ptrs = true,
9307-
.vmhub = AMDGPU_GFXHUB_0,
93089308
.get_rptr = gfx_v10_0_ring_get_rptr_compute,
93099309
.get_wptr = gfx_v10_0_ring_get_wptr_compute,
93109310
.set_wptr = gfx_v10_0_ring_set_wptr_compute,
@@ -9340,7 +9340,6 @@ static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_kiq = {
93409340
.align_mask = 0xff,
93419341
.nop = PACKET3(PACKET3_NOP, 0x3FFF),
93429342
.support_64bit_ptrs = true,
9343-
.vmhub = AMDGPU_GFXHUB_0,
93449343
.get_rptr = gfx_v10_0_ring_get_rptr_compute,
93459344
.get_wptr = gfx_v10_0_ring_get_wptr_compute,
93469345
.set_wptr = gfx_v10_0_ring_set_wptr_compute,

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,7 @@ static int gfx_v11_0_gfx_ring_init(struct amdgpu_device *adev, int ring_id,
866866
ring->doorbell_index = adev->doorbell_index.gfx_ring0 << 1;
867867
else
868868
ring->doorbell_index = adev->doorbell_index.gfx_ring1 << 1;
869+
ring->vm_hub = AMDGPU_GFXHUB_0;
869870
sprintf(ring->name, "gfx_%d.%d.%d", ring->me, ring->pipe, ring->queue);
870871

871872
irq_type = AMDGPU_CP_IRQ_GFX_ME0_PIPE0_EOP + ring->pipe;
@@ -896,6 +897,7 @@ static int gfx_v11_0_compute_ring_init(struct amdgpu_device *adev, int ring_id,
896897
ring->doorbell_index = (adev->doorbell_index.mec_ring0 + ring_id) << 1;
897898
ring->eop_gpu_addr = adev->gfx.mec.hpd_eop_gpu_addr
898899
+ (ring_id * GFX11_MEC_HPD_SIZE);
900+
ring->vm_hub = AMDGPU_GFXHUB_0;
899901
sprintf(ring->name, "comp_%d.%d.%d", ring->me, ring->pipe, ring->queue);
900902

901903
irq_type = AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP
@@ -6204,7 +6206,6 @@ static const struct amdgpu_ring_funcs gfx_v11_0_ring_funcs_gfx = {
62046206
.nop = PACKET3(PACKET3_NOP, 0x3FFF),
62056207
.support_64bit_ptrs = true,
62066208
.secure_submission_supported = true,
6207-
.vmhub = AMDGPU_GFXHUB_0,
62086209
.get_rptr = gfx_v11_0_ring_get_rptr_gfx,
62096210
.get_wptr = gfx_v11_0_ring_get_wptr_gfx,
62106211
.set_wptr = gfx_v11_0_ring_set_wptr_gfx,
@@ -6252,7 +6253,6 @@ static const struct amdgpu_ring_funcs gfx_v11_0_ring_funcs_compute = {
62526253
.align_mask = 0xff,
62536254
.nop = PACKET3(PACKET3_NOP, 0x3FFF),
62546255
.support_64bit_ptrs = true,
6255-
.vmhub = AMDGPU_GFXHUB_0,
62566256
.get_rptr = gfx_v11_0_ring_get_rptr_compute,
62576257
.get_wptr = gfx_v11_0_ring_get_wptr_compute,
62586258
.set_wptr = gfx_v11_0_ring_set_wptr_compute,
@@ -6288,7 +6288,6 @@ static const struct amdgpu_ring_funcs gfx_v11_0_ring_funcs_kiq = {
62886288
.align_mask = 0xff,
62896289
.nop = PACKET3(PACKET3_NOP, 0x3FFF),
62906290
.support_64bit_ptrs = true,
6291-
.vmhub = AMDGPU_GFXHUB_0,
62926291
.get_rptr = gfx_v11_0_ring_get_rptr_compute,
62936292
.get_wptr = gfx_v11_0_ring_get_wptr_compute,
62946293
.set_wptr = gfx_v11_0_ring_set_wptr_compute,

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,6 +2005,7 @@ static int gfx_v9_0_compute_ring_init(struct amdgpu_device *adev, int ring_id,
20052005
ring->doorbell_index = (adev->doorbell_index.mec_ring0 + ring_id) << 1;
20062006
ring->eop_gpu_addr = adev->gfx.mec.hpd_eop_gpu_addr
20072007
+ (ring_id * GFX9_MEC_HPD_SIZE);
2008+
ring->vm_hub = AMDGPU_GFXHUB_0;
20082009
sprintf(ring->name, "comp_%d.%d.%d", ring->me, ring->pipe, ring->queue);
20092010

20102011
irq_type = AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP
@@ -2104,6 +2105,7 @@ static int gfx_v9_0_sw_init(void *handle)
21042105

21052106
/* disable scheduler on the real ring */
21062107
ring->no_scheduler = true;
2108+
ring->vm_hub = AMDGPU_GFXHUB_0;
21072109
r = amdgpu_ring_init(adev, ring, 1024, &adev->gfx.eop_irq,
21082110
AMDGPU_CP_IRQ_GFX_ME0_PIPE0_EOP,
21092111
AMDGPU_RING_PRIO_DEFAULT, NULL);
@@ -2121,6 +2123,7 @@ static int gfx_v9_0_sw_init(void *handle)
21212123
ring->doorbell_index = adev->doorbell_index.gfx_ring0 << 1;
21222124
ring->is_sw_ring = true;
21232125
hw_prio = amdgpu_sw_ring_priority(i);
2126+
ring->vm_hub = AMDGPU_GFXHUB_0;
21242127
r = amdgpu_ring_init(adev, ring, 1024, &adev->gfx.eop_irq,
21252128
AMDGPU_CP_IRQ_GFX_ME0_PIPE0_EOP, hw_prio,
21262129
NULL);
@@ -6790,7 +6793,6 @@ static const struct amdgpu_ring_funcs gfx_v9_0_ring_funcs_gfx = {
67906793
.nop = PACKET3(PACKET3_NOP, 0x3FFF),
67916794
.support_64bit_ptrs = true,
67926795
.secure_submission_supported = true,
6793-
.vmhub = AMDGPU_GFXHUB_0,
67946796
.get_rptr = gfx_v9_0_ring_get_rptr_gfx,
67956797
.get_wptr = gfx_v9_0_ring_get_wptr_gfx,
67966798
.set_wptr = gfx_v9_0_ring_set_wptr_gfx,
@@ -6844,7 +6846,6 @@ static const struct amdgpu_ring_funcs gfx_v9_0_sw_ring_funcs_gfx = {
68446846
.nop = PACKET3(PACKET3_NOP, 0x3FFF),
68456847
.support_64bit_ptrs = true,
68466848
.secure_submission_supported = true,
6847-
.vmhub = AMDGPU_GFXHUB_0,
68486849
.get_rptr = amdgpu_sw_ring_get_rptr_gfx,
68496850
.get_wptr = amdgpu_sw_ring_get_wptr_gfx,
68506851
.set_wptr = amdgpu_sw_ring_set_wptr_gfx,
@@ -6898,7 +6899,6 @@ static const struct amdgpu_ring_funcs gfx_v9_0_ring_funcs_compute = {
68986899
.align_mask = 0xff,
68996900
.nop = PACKET3(PACKET3_NOP, 0x3FFF),
69006901
.support_64bit_ptrs = true,
6901-
.vmhub = AMDGPU_GFXHUB_0,
69026902
.get_rptr = gfx_v9_0_ring_get_rptr_compute,
69036903
.get_wptr = gfx_v9_0_ring_get_wptr_compute,
69046904
.set_wptr = gfx_v9_0_ring_set_wptr_compute,
@@ -6937,7 +6937,6 @@ static const struct amdgpu_ring_funcs gfx_v9_0_ring_funcs_kiq = {
69376937
.align_mask = 0xff,
69386938
.nop = PACKET3(PACKET3_NOP, 0x3FFF),
69396939
.support_64bit_ptrs = true,
6940-
.vmhub = AMDGPU_GFXHUB_0,
69416940
.get_rptr = gfx_v9_0_ring_get_rptr_compute,
69426941
.get_wptr = gfx_v9_0_ring_get_wptr_compute,
69436942
.set_wptr = gfx_v9_0_ring_set_wptr_compute,

0 commit comments

Comments
 (0)