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

drm/amdkfd: Added device queue manager files for GFX12.

Initial implementation, based on GFX11.

v2: squash in include fix from David (Alex)

Signed-off-by: David Belanger <david.belanger@amd.com>
Reviewed-by: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

David Belanger and committed by
Alex Deucher
47fa09b7 48f0bdf4

+87 -1
+1
drivers/gpu/drm/amd/amdkfd/Makefile
··· 50 50 $(AMDKFD_PATH)/kfd_device_queue_manager_v9.o \ 51 51 $(AMDKFD_PATH)/kfd_device_queue_manager_v10.o \ 52 52 $(AMDKFD_PATH)/kfd_device_queue_manager_v11.o \ 53 + $(AMDKFD_PATH)/kfd_device_queue_manager_v12.o \ 53 54 $(AMDKFD_PATH)/kfd_interrupt.o \ 54 55 $(AMDKFD_PATH)/kfd_events.o \ 55 56 $(AMDKFD_PATH)/cik_event_interrupt.o \
+3 -1
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
··· 2597 2597 break; 2598 2598 2599 2599 default: 2600 - if (KFD_GC_VERSION(dev) >= IP_VERSION(11, 0, 0)) 2600 + if (KFD_GC_VERSION(dev) >= IP_VERSION(12, 0, 0)) 2601 + device_queue_manager_init_v12(&dqm->asic_ops); 2602 + else if (KFD_GC_VERSION(dev) >= IP_VERSION(11, 0, 0)) 2601 2603 device_queue_manager_init_v11(&dqm->asic_ops); 2602 2604 else if (KFD_GC_VERSION(dev) >= IP_VERSION(10, 1, 1)) 2603 2605 device_queue_manager_init_v10(&dqm->asic_ops);
+2
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h
··· 277 277 struct device_queue_manager_asic_ops *asic_ops); 278 278 void device_queue_manager_init_v11( 279 279 struct device_queue_manager_asic_ops *asic_ops); 280 + void device_queue_manager_init_v12( 281 + struct device_queue_manager_asic_ops *asic_ops); 280 282 void program_sh_mem_settings(struct device_queue_manager *dqm, 281 283 struct qcm_process_device *qpd); 282 284 unsigned int get_cp_queues_num(struct device_queue_manager *dqm);
+81
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v12.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 OR MIT 2 + /* 3 + * Copyright 2023 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 + 25 + #include "kfd_device_queue_manager.h" 26 + #include "gc/gc_12_0_0_sh_mask.h" 27 + #include "soc24_enum.h" 28 + 29 + static int update_qpd_v12(struct device_queue_manager *dqm, 30 + struct qcm_process_device *qpd); 31 + static void init_sdma_vm_v12(struct device_queue_manager *dqm, struct queue *q, 32 + struct qcm_process_device *qpd); 33 + 34 + void device_queue_manager_init_v12( 35 + struct device_queue_manager_asic_ops *asic_ops) 36 + { 37 + asic_ops->update_qpd = update_qpd_v12; 38 + asic_ops->init_sdma_vm = init_sdma_vm_v12; 39 + asic_ops->mqd_manager_init = mqd_manager_init_v12; 40 + } 41 + 42 + static uint32_t compute_sh_mem_bases_64bit(struct kfd_process_device *pdd) 43 + { 44 + uint32_t shared_base = pdd->lds_base >> 48; 45 + uint32_t private_base = pdd->scratch_base >> 48; 46 + 47 + return (shared_base << SH_MEM_BASES__SHARED_BASE__SHIFT) | 48 + private_base; 49 + } 50 + 51 + static int update_qpd_v12(struct device_queue_manager *dqm, 52 + struct qcm_process_device *qpd) 53 + { 54 + struct kfd_process_device *pdd; 55 + 56 + pdd = qpd_to_pdd(qpd); 57 + 58 + /* check if sh_mem_config register already configured */ 59 + if (qpd->sh_mem_config == 0) { 60 + qpd->sh_mem_config = 61 + (SH_MEM_ALIGNMENT_MODE_UNALIGNED << 62 + SH_MEM_CONFIG__ALIGNMENT_MODE__SHIFT) | 63 + (3 << SH_MEM_CONFIG__INITIAL_INST_PREFETCH__SHIFT); 64 + 65 + qpd->sh_mem_ape1_limit = 0; 66 + qpd->sh_mem_ape1_base = 0; 67 + } 68 + 69 + qpd->sh_mem_bases = compute_sh_mem_bases_64bit(pdd); 70 + 71 + pr_debug("sh_mem_bases 0x%X\n", qpd->sh_mem_bases); 72 + 73 + return 0; 74 + } 75 + 76 + static void init_sdma_vm_v12(struct device_queue_manager *dqm, struct queue *q, 77 + struct qcm_process_device *qpd) 78 + { 79 + /* Not needed on SDMAv4 onwards any more */ 80 + q->properties.sdma_vm_addr = 0; 81 + }