Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <Arunpravin.PaneerSelvam@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Arunpravin Paneer Selvam and committed by
Alex Deucher
e34bcf15 335f1e79

+120 -23
+5 -5
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
··· 36 36 #include "gc/gc_12_0_0_offset.h" 37 37 #include "gc/gc_12_0_0_sh_mask.h" 38 38 #include "soc24_enum.h" 39 - #include "ivsrcid/gfx/irqsrcs_gfx_11_0_0.h" 39 + #include "ivsrcid/gfx/irqsrcs_gfx_12_0_0.h" 40 40 41 41 #include "soc15.h" 42 42 #include "clearstate_gfx12.h" ··· 1453 1453 1454 1454 /* EOP Event */ 1455 1455 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, 1457 1457 &adev->gfx.eop_irq); 1458 1458 if (r) 1459 1459 return r; 1460 1460 1461 1461 /* Bad opcode Event */ 1462 1462 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, 1464 1464 &adev->gfx.bad_op_irq); 1465 1465 if (r) 1466 1466 return r; 1467 1467 1468 1468 /* Privileged reg */ 1469 1469 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, 1471 1471 &adev->gfx.priv_reg_irq); 1472 1472 if (r) 1473 1473 return r; 1474 1474 1475 1475 /* Privileged inst */ 1476 1476 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, 1478 1478 &adev->gfx.priv_inst_irq); 1479 1479 if (r) 1480 1480 return r;
+41 -18
drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c
··· 33 33 #include "gc/gc_12_0_0_offset.h" 34 34 #include "gc/gc_12_0_0_sh_mask.h" 35 35 #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" 37 37 38 38 #include "soc15_common.h" 39 39 #include "soc15.h" ··· 43 43 #include "sdma_v7_0.h" 44 44 #include "v12_structs.h" 45 45 #include "mes_userqueue.h" 46 + #include "amdgpu_userq_fence.h" 46 47 47 48 MODULE_FIRMWARE("amdgpu/sdma_7_0_0.bin"); 48 49 MODULE_FIRMWARE("amdgpu/sdma_7_0_1.bin"); ··· 911 910 m->sdmax_rlcx_csa_addr_lo = lower_32_bits(prop->csa_addr); 912 911 m->sdmax_rlcx_csa_addr_hi = upper_32_bits(prop->csa_addr); 913 912 913 + m->sdmax_rlcx_mcu_dbg0 = lower_32_bits(prop->fence_address); 914 + m->sdmax_rlcx_mcu_dbg1 = upper_32_bits(prop->fence_address); 915 + 914 916 return 0; 915 917 } 916 918 ··· 1300 1296 1301 1297 /* SDMA trap event */ 1302 1298 r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GFX, 1303 - GFX_11_0_0__SRCID__SDMA_TRAP, 1299 + GFX_12_0_0__SRCID__SDMA_TRAP, 1304 1300 &adev->sdma.trap_irq); 1301 + if (r) 1302 + return r; 1303 + 1304 + /* SDMA user fence event */ 1305 + r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GFX, 1306 + GFX_12_0_0__SRCID__SDMA_FENCE, 1307 + &adev->sdma.fence_irq); 1305 1308 if (r) 1306 1309 return r; 1307 1310 ··· 1537 1526 struct amdgpu_iv_entry *entry) 1538 1527 { 1539 1528 int instances, queue; 1540 - uint32_t mes_queue_id = entry->src_data[0]; 1541 1529 1542 1530 DRM_DEBUG("IH: SDMA trap\n"); 1543 - 1544 - if (adev->enable_mes && (mes_queue_id & AMDGPU_FENCE_MES_QUEUE_FLAG)) { 1545 - struct amdgpu_mes_queue *queue; 1546 - 1547 - mes_queue_id &= AMDGPU_FENCE_MES_QUEUE_ID_MASK; 1548 - 1549 - spin_lock(&adev->mes.queue_id_lock); 1550 - queue = idr_find(&adev->mes.queue_id_idr, mes_queue_id); 1551 - if (queue) { 1552 - DRM_DEBUG("process smda queue id = %d\n", mes_queue_id); 1553 - amdgpu_fence_process(queue->ring); 1554 - } 1555 - spin_unlock(&adev->mes.queue_id_lock); 1556 - return 0; 1557 - } 1558 1531 1559 1532 queue = entry->ring_id & 0xf; 1560 1533 instances = (entry->ring_id & 0xf0) >> 4; ··· 1558 1563 } 1559 1564 break; 1560 1565 } 1566 + return 0; 1567 + } 1568 + 1569 + static int sdma_v7_0_process_fence_irq(struct amdgpu_device *adev, 1570 + struct amdgpu_irq_src *source, 1571 + struct amdgpu_iv_entry *entry) 1572 + { 1573 + u32 doorbell_offset = entry->src_data[0]; 1574 + 1575 + if (adev->enable_mes && doorbell_offset) { 1576 + struct amdgpu_userq_fence_driver *fence_drv = NULL; 1577 + struct xarray *xa = &adev->userq_xa; 1578 + unsigned long flags; 1579 + 1580 + doorbell_offset >>= SDMA0_QUEUE0_DOORBELL_OFFSET__OFFSET__SHIFT; 1581 + 1582 + xa_lock_irqsave(xa, flags); 1583 + fence_drv = xa_load(xa, doorbell_offset); 1584 + if (fence_drv) 1585 + amdgpu_userq_fence_driver_process(fence_drv); 1586 + xa_unlock_irqrestore(xa, flags); 1587 + } 1588 + 1561 1589 return 0; 1562 1590 } 1563 1591 ··· 1721 1703 .process = sdma_v7_0_process_trap_irq, 1722 1704 }; 1723 1705 1706 + static const struct amdgpu_irq_src_funcs sdma_v7_0_fence_irq_funcs = { 1707 + .process = sdma_v7_0_process_fence_irq, 1708 + }; 1709 + 1724 1710 static const struct amdgpu_irq_src_funcs sdma_v7_0_illegal_inst_irq_funcs = { 1725 1711 .process = sdma_v7_0_process_illegal_inst_irq, 1726 1712 }; ··· 1734 1712 adev->sdma.trap_irq.num_types = AMDGPU_SDMA_IRQ_INSTANCE0 + 1735 1713 adev->sdma.num_instances; 1736 1714 adev->sdma.trap_irq.funcs = &sdma_v7_0_trap_irq_funcs; 1715 + adev->sdma.fence_irq.funcs = &sdma_v7_0_fence_irq_funcs; 1737 1716 adev->sdma.illegal_inst_irq.funcs = &sdma_v7_0_illegal_inst_irq_funcs; 1738 1717 } 1739 1718
+74
drivers/gpu/drm/amd/include/ivsrcid/gfx/irqsrcs_gfx_12_0_0.h
··· 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