Skip to content

Commit e34bcf1

Browse files
arunpravin24alexdeucher
authored andcommitted
drm/amdgpu: Add userq fence support to SDMAv7.0
- Add userq fence support to SDMAv7.0. - GFX12's user fence irq src id differs from GFX11's, hence we need create a new irq srcid header file for GFX12. User fence irq src id information- GFX11 and SDMA6.0 - 0x43 GFX12 and SDMA7.0 - 0x46 Signed-off-by: Arunpravin Paneer Selvam <[email protected]> Acked-by: Christian König <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 335f1e7 commit e34bcf1

File tree

3 files changed

+120
-23
lines changed

3 files changed

+120
-23
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include "gc/gc_12_0_0_offset.h"
3737
#include "gc/gc_12_0_0_sh_mask.h"
3838
#include "soc24_enum.h"
39-
#include "ivsrcid/gfx/irqsrcs_gfx_11_0_0.h"
39+
#include "ivsrcid/gfx/irqsrcs_gfx_12_0_0.h"
4040

4141
#include "soc15.h"
4242
#include "clearstate_gfx12.h"
@@ -1453,28 +1453,28 @@ static int gfx_v12_0_sw_init(struct amdgpu_ip_block *ip_block)
14531453

14541454
/* EOP Event */
14551455
r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GRBM_CP,
1456-
GFX_11_0_0__SRCID__CP_EOP_INTERRUPT,
1456+
GFX_12_0_0__SRCID__CP_EOP_INTERRUPT,
14571457
&adev->gfx.eop_irq);
14581458
if (r)
14591459
return r;
14601460

14611461
/* Bad opcode Event */
14621462
r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GRBM_CP,
1463-
GFX_11_0_0__SRCID__CP_BAD_OPCODE_ERROR,
1463+
GFX_12_0_0__SRCID__CP_BAD_OPCODE_ERROR,
14641464
&adev->gfx.bad_op_irq);
14651465
if (r)
14661466
return r;
14671467

14681468
/* Privileged reg */
14691469
r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GRBM_CP,
1470-
GFX_11_0_0__SRCID__CP_PRIV_REG_FAULT,
1470+
GFX_12_0_0__SRCID__CP_PRIV_REG_FAULT,
14711471
&adev->gfx.priv_reg_irq);
14721472
if (r)
14731473
return r;
14741474

14751475
/* Privileged inst */
14761476
r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GRBM_CP,
1477-
GFX_11_0_0__SRCID__CP_PRIV_INSTR_FAULT,
1477+
GFX_12_0_0__SRCID__CP_PRIV_INSTR_FAULT,
14781478
&adev->gfx.priv_inst_irq);
14791479
if (r)
14801480
return r;

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

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "gc/gc_12_0_0_offset.h"
3434
#include "gc/gc_12_0_0_sh_mask.h"
3535
#include "hdp/hdp_6_0_0_offset.h"
36-
#include "ivsrcid/gfx/irqsrcs_gfx_11_0_0.h"
36+
#include "ivsrcid/gfx/irqsrcs_gfx_12_0_0.h"
3737

3838
#include "soc15_common.h"
3939
#include "soc15.h"
@@ -43,6 +43,7 @@
4343
#include "sdma_v7_0.h"
4444
#include "v12_structs.h"
4545
#include "mes_userqueue.h"
46+
#include "amdgpu_userq_fence.h"
4647

4748
MODULE_FIRMWARE("amdgpu/sdma_7_0_0.bin");
4849
MODULE_FIRMWARE("amdgpu/sdma_7_0_1.bin");
@@ -910,6 +911,9 @@ static int sdma_v7_0_mqd_init(struct amdgpu_device *adev, void *mqd,
910911
m->sdmax_rlcx_csa_addr_lo = lower_32_bits(prop->csa_addr);
911912
m->sdmax_rlcx_csa_addr_hi = upper_32_bits(prop->csa_addr);
912913

914+
m->sdmax_rlcx_mcu_dbg0 = lower_32_bits(prop->fence_address);
915+
m->sdmax_rlcx_mcu_dbg1 = upper_32_bits(prop->fence_address);
916+
913917
return 0;
914918
}
915919

@@ -1296,11 +1300,18 @@ static int sdma_v7_0_sw_init(struct amdgpu_ip_block *ip_block)
12961300

12971301
/* SDMA trap event */
12981302
r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GFX,
1299-
GFX_11_0_0__SRCID__SDMA_TRAP,
1303+
GFX_12_0_0__SRCID__SDMA_TRAP,
13001304
&adev->sdma.trap_irq);
13011305
if (r)
13021306
return r;
13031307

1308+
/* SDMA user fence event */
1309+
r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GFX,
1310+
GFX_12_0_0__SRCID__SDMA_FENCE,
1311+
&adev->sdma.fence_irq);
1312+
if (r)
1313+
return r;
1314+
13041315
for (i = 0; i < adev->sdma.num_instances; i++) {
13051316
ring = &adev->sdma.instance[i].ring;
13061317
ring->ring_obj = NULL;
@@ -1526,25 +1537,9 @@ static int sdma_v7_0_process_trap_irq(struct amdgpu_device *adev,
15261537
struct amdgpu_iv_entry *entry)
15271538
{
15281539
int instances, queue;
1529-
uint32_t mes_queue_id = entry->src_data[0];
15301540

15311541
DRM_DEBUG("IH: SDMA trap\n");
15321542

1533-
if (adev->enable_mes && (mes_queue_id & AMDGPU_FENCE_MES_QUEUE_FLAG)) {
1534-
struct amdgpu_mes_queue *queue;
1535-
1536-
mes_queue_id &= AMDGPU_FENCE_MES_QUEUE_ID_MASK;
1537-
1538-
spin_lock(&adev->mes.queue_id_lock);
1539-
queue = idr_find(&adev->mes.queue_id_idr, mes_queue_id);
1540-
if (queue) {
1541-
DRM_DEBUG("process smda queue id = %d\n", mes_queue_id);
1542-
amdgpu_fence_process(queue->ring);
1543-
}
1544-
spin_unlock(&adev->mes.queue_id_lock);
1545-
return 0;
1546-
}
1547-
15481543
queue = entry->ring_id & 0xf;
15491544
instances = (entry->ring_id & 0xf0) >> 4;
15501545
if (instances > 1) {
@@ -1566,6 +1561,29 @@ static int sdma_v7_0_process_trap_irq(struct amdgpu_device *adev,
15661561
return 0;
15671562
}
15681563

1564+
static int sdma_v7_0_process_fence_irq(struct amdgpu_device *adev,
1565+
struct amdgpu_irq_src *source,
1566+
struct amdgpu_iv_entry *entry)
1567+
{
1568+
u32 doorbell_offset = entry->src_data[0];
1569+
1570+
if (adev->enable_mes && doorbell_offset) {
1571+
struct amdgpu_userq_fence_driver *fence_drv = NULL;
1572+
struct xarray *xa = &adev->userq_xa;
1573+
unsigned long flags;
1574+
1575+
doorbell_offset >>= SDMA0_QUEUE0_DOORBELL_OFFSET__OFFSET__SHIFT;
1576+
1577+
xa_lock_irqsave(xa, flags);
1578+
fence_drv = xa_load(xa, doorbell_offset);
1579+
if (fence_drv)
1580+
amdgpu_userq_fence_driver_process(fence_drv);
1581+
xa_unlock_irqrestore(xa, flags);
1582+
}
1583+
1584+
return 0;
1585+
}
1586+
15691587
static int sdma_v7_0_process_illegal_inst_irq(struct amdgpu_device *adev,
15701588
struct amdgpu_irq_src *source,
15711589
struct amdgpu_iv_entry *entry)
@@ -1703,6 +1721,10 @@ static const struct amdgpu_irq_src_funcs sdma_v7_0_trap_irq_funcs = {
17031721
.process = sdma_v7_0_process_trap_irq,
17041722
};
17051723

1724+
static const struct amdgpu_irq_src_funcs sdma_v7_0_fence_irq_funcs = {
1725+
.process = sdma_v7_0_process_fence_irq,
1726+
};
1727+
17061728
static const struct amdgpu_irq_src_funcs sdma_v7_0_illegal_inst_irq_funcs = {
17071729
.process = sdma_v7_0_process_illegal_inst_irq,
17081730
};
@@ -1712,6 +1734,7 @@ static void sdma_v7_0_set_irq_funcs(struct amdgpu_device *adev)
17121734
adev->sdma.trap_irq.num_types = AMDGPU_SDMA_IRQ_INSTANCE0 +
17131735
adev->sdma.num_instances;
17141736
adev->sdma.trap_irq.funcs = &sdma_v7_0_trap_irq_funcs;
1737+
adev->sdma.fence_irq.funcs = &sdma_v7_0_fence_irq_funcs;
17151738
adev->sdma.illegal_inst_irq.funcs = &sdma_v7_0_illegal_inst_irq_funcs;
17161739
}
17171740

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/* SPDX-License-Identifier: MIT */
2+
/*
3+
* Copyright 2024 Advanced Micro Devices, Inc.
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a
6+
* copy of this software and associated documentation files (the "Software"),
7+
* to deal in the Software without restriction, including without limitation
8+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
9+
* and/or sell copies of the Software, and to permit persons to whom the
10+
* Software is furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18+
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19+
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21+
* OTHER DEALINGS IN THE SOFTWARE.
22+
*
23+
*/
24+
#ifndef __IRQSRCS_GFX_12_0_0_H__
25+
#define __IRQSRCS_GFX_12_0_0_H__
26+
27+
#define GFX_12_0_0__SRCID__UTCL2_FAULT 0 // UTCL2 has encountered a fault or retry scenario
28+
#define GFX_12_0_0__SRCID__UTCL2_DATA_POISONING 1 // UTCL2 for data poisoning
29+
#define GFX_12_0_0__SRCID__MEM_ACCES_MON 10 // 0x0A EA memory access monitor interrupt
30+
#define GFX_12_0_0__SRCID__SDMA_ATOMIC_RTN_DONE 48 // 0x30 SDMA atomic*_rtn ops complete
31+
#define GFX_12_0_0__SRCID__SDMA_TRAP 49 // 0x31 Trap
32+
#define GFX_12_0_0__SRCID__SDMA_SRBMWRITE 50 // 0x32 SRBM write Protection
33+
#define GFX_12_0_0__SRCID__SDMA_CTXEMPTY 51 // 0x33 Context Empty
34+
#define GFX_12_0_0__SRCID__SDMA_PREEMPT 52 // 0x34 SDMA New Run List
35+
#define GFX_12_0_0__SRCID__SDMA_IB_PREEMPT 53 // 0x35 sdma mid - command buffer preempt interrupt
36+
#define GFX_12_0_0__SRCID__SDMA_DOORBELL_INVALID 54 // 0x36 Doorbell BE invalid
37+
#define GFX_12_0_0__SRCID__SDMA_QUEUE_HANG 55 // 0x37 Queue hang or Command timeout
38+
#define GFX_12_0_0__SRCID__SDMA_ATOMIC_TIMEOUT 56 // 0x38 SDMA atomic CMPSWAP loop timeout
39+
#define GFX_12_0_0__SRCID__SDMA_POLL_TIMEOUT 57 // 0x39 SRBM read poll timeout
40+
#define GFX_12_0_0__SRCID__SDMA_PAGE_TIMEOUT 58 // 0x3A Page retry timeout after UTCL2 return nack = 1
41+
#define GFX_12_0_0__SRCID__SDMA_PAGE_NULL 59 // 0x3B Page Null from UTCL2 when nack = 2
42+
#define GFX_12_0_0__SRCID__SDMA_PAGE_FAULT 60 // 0x3C Page Fault Error from UTCL2 when nack = 3
43+
#define GFX_12_0_0__SRCID__SDMA_VM_HOLE 61 // 0x3D MC or SEM address in VM hole
44+
#define GFX_12_0_0__SRCID__SDMA_ECC 62 // 0x3E ECC Error
45+
#define GFX_12_0_0__SRCID__SDMA_FROZEN 63 // 0x3F SDMA Frozen
46+
#define GFX_12_0_0__SRCID__SDMA_SRAM_ECC 64 // 0x40 SRAM ECC Error
47+
#define GFX_12_0_0__SRCID__SDMA_SEM_INCOMPLETE_TIMEOUT 65 // 0x41 GPF(Sem incomplete timeout)
48+
#define GFX_12_0_0__SRCID__SDMA_SEM_WAIT_FAIL_TIMEOUT 66 // 0x42 Semaphore wait fail timeout
49+
#define GFX_12_0_0__SRCID__SDMA_FENCE 70 // 0x46 User fence
50+
#define GFX_12_0_0__SRCID__RLC_GC_FED_INTERRUPT 128 // 0x80 FED Interrupt (for data poisoning)
51+
#define GFX_12_0_0__SRCID__CP_GENERIC_INT 177 // 0xB1 CP_GENERIC int
52+
#define GFX_12_0_0__SRCID__CP_PM4_PKT_RSVD_BIT_ERROR 180 // 0xB4 PM4 Pkt Rsvd Bits Error
53+
#define GFX_12_0_0__SRCID__CP_EOP_INTERRUPT 181 // 0xB5 End-of-Pipe Interrupt
54+
#define GFX_12_0_0__SRCID__CP_BAD_OPCODE_ERROR 183 // 0xB7 Bad Opcode Error
55+
#define GFX_12_0_0__SRCID__CP_PRIV_REG_FAULT 184 // 0xB8 Privileged Register Fault
56+
#define GFX_12_0_0__SRCID__CP_PRIV_INSTR_FAULT 185 // 0xB9 Privileged Instr Fault
57+
#define GFX_12_0_0__SRCID__CP_WAIT_MEM_SEM_FAULT 186 // 0xBA Wait Memory Semaphore Fault (Sync Object Fault)
58+
#define GFX_12_0_0__SRCID__CP_CTX_EMPTY_INTERRUPT 187 // 0xBB Context Empty Interrupt
59+
#define GFX_12_0_0__SRCID__CP_CTX_BUSY_INTERRUPT 188 // 0xBC Context Busy Interrupt
60+
#define GFX_12_0_0__SRCID__CP_ME_WAIT_REG_MEM_POLL_TIMEOUT 192 // 0xC0 CP.ME Wait_Reg_Mem Poll Timeout
61+
#define GFX_12_0_0__SRCID__CP_SIG_INCOMPLETE 193 // 0xC1 "Surface Probe Fault Signal Incomplete"
62+
#define GFX_12_0_0__SRCID__CP_PREEMPT_ACK 194 // 0xC2 Preemption Ack-wledge
63+
#define GFX_12_0_0__SRCID__CP_GPF 195 // 0xC3 General Protection Fault (GPF)
64+
#define GFX_12_0_0__SRCID__CP_GDS_ALLOC_ERROR 196 // 0xC4 GDS Alloc Error
65+
#define GFX_12_0_0__SRCID__CP_ECC_ERROR 197 // 0xC5 ECC Error
66+
#define GFX_12_0_0__SRCID__CP_COMPUTE_QUERY_STATUS 199 // 0xC7 Compute query status
67+
#define GFX_12_0_0__SRCID__CP_VM_DOORBELL 200 // 0xC8 Unattached VM Doorbell Received
68+
#define GFX_12_0_0__SRCID__CP_FUE_ERROR 201 // 0xC9 ECC FUE Error
69+
#define GFX_12_0_0__SRCID__RLC_STRM_PERF_MONITOR_INTERRUPT 202 // 0xCA Streaming Perf Monitor Interrupt
70+
#define GFX_12_0_0__SRCID__GRBM_RD_TIMEOUT_ERROR 232 // 0xE8 CRead timeout error
71+
#define GFX_12_0_0__SRCID__GRBM_REG_GUI_IDLE 233 // 0xE9 Register GUI Idle
72+
#define GFX_12_0_0__SRCID__SQ_INTERRUPT_ID 239 // 0xEF SQ Interrupt (ttrace wrap, errors)
73+
74+
#endif

0 commit comments

Comments
 (0)