]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
drm/amdkfd: Added device queue manager files for GFX12.
authorDavid Belanger <david.belanger@amd.com>
Tue, 16 May 2023 16:27:14 +0000 (12:27 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 2 May 2024 20:18:12 +0000 (16:18 -0400)
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>
drivers/gpu/drm/amd/amdkfd/Makefile
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v12.c [new file with mode: 0644]

index f0d9eebf242b6918a3f12149a819b96e50f7eac5..0d3d8972240daf0ed84b61c5a043a458b8784f5c 100644 (file)
@@ -50,6 +50,7 @@ AMDKFD_FILES  := $(AMDKFD_PATH)/kfd_module.o \
                $(AMDKFD_PATH)/kfd_device_queue_manager_v9.o \
                $(AMDKFD_PATH)/kfd_device_queue_manager_v10.o \
                $(AMDKFD_PATH)/kfd_device_queue_manager_v11.o \
+               $(AMDKFD_PATH)/kfd_device_queue_manager_v12.o \
                $(AMDKFD_PATH)/kfd_interrupt.o \
                $(AMDKFD_PATH)/kfd_events.o \
                $(AMDKFD_PATH)/cik_event_interrupt.o \
index c08b6ee252898d96981c16a8d739e7779778c802..4721b2fccd068ea09aa2cb0eaccb40ccf0973868 100644 (file)
@@ -2597,7 +2597,9 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_node *dev)
                break;
 
        default:
-               if (KFD_GC_VERSION(dev) >= IP_VERSION(11, 0, 0))
+               if (KFD_GC_VERSION(dev) >= IP_VERSION(12, 0, 0))
+                       device_queue_manager_init_v12(&dqm->asic_ops);
+               else if (KFD_GC_VERSION(dev) >= IP_VERSION(11, 0, 0))
                        device_queue_manager_init_v11(&dqm->asic_ops);
                else if (KFD_GC_VERSION(dev) >= IP_VERSION(10, 1, 1))
                        device_queue_manager_init_v10(&dqm->asic_ops);
index cf7e182588f8072c5228a97edb032a2c9707fdb0..fcc0ee67f5441bed44f7a1ca311077b7c28dd66f 100644 (file)
@@ -277,6 +277,8 @@ void device_queue_manager_init_v10(
                struct device_queue_manager_asic_ops *asic_ops);
 void device_queue_manager_init_v11(
                struct device_queue_manager_asic_ops *asic_ops);
+void device_queue_manager_init_v12(
+               struct device_queue_manager_asic_ops *asic_ops);
 void program_sh_mem_settings(struct device_queue_manager *dqm,
                                        struct qcm_process_device *qpd);
 unsigned int get_cp_queues_num(struct device_queue_manager *dqm);
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v12.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v12.c
new file mode 100644 (file)
index 0000000..4f3295b
--- /dev/null
@@ -0,0 +1,81 @@
+// SPDX-License-Identifier: GPL-2.0 OR MIT
+/*
+ * Copyright 2023 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "kfd_device_queue_manager.h"
+#include "gc/gc_12_0_0_sh_mask.h"
+#include "soc24_enum.h"
+
+static int update_qpd_v12(struct device_queue_manager *dqm,
+                        struct qcm_process_device *qpd);
+static void init_sdma_vm_v12(struct device_queue_manager *dqm, struct queue *q,
+                           struct qcm_process_device *qpd);
+
+void device_queue_manager_init_v12(
+       struct device_queue_manager_asic_ops *asic_ops)
+{
+       asic_ops->update_qpd = update_qpd_v12;
+       asic_ops->init_sdma_vm = init_sdma_vm_v12;
+       asic_ops->mqd_manager_init = mqd_manager_init_v12;
+}
+
+static uint32_t compute_sh_mem_bases_64bit(struct kfd_process_device *pdd)
+{
+       uint32_t shared_base = pdd->lds_base >> 48;
+       uint32_t private_base = pdd->scratch_base >> 48;
+
+       return (shared_base << SH_MEM_BASES__SHARED_BASE__SHIFT) |
+               private_base;
+}
+
+static int update_qpd_v12(struct device_queue_manager *dqm,
+                        struct qcm_process_device *qpd)
+{
+       struct kfd_process_device *pdd;
+
+       pdd = qpd_to_pdd(qpd);
+
+       /* check if sh_mem_config register already configured */
+       if (qpd->sh_mem_config == 0) {
+               qpd->sh_mem_config =
+                       (SH_MEM_ALIGNMENT_MODE_UNALIGNED <<
+                               SH_MEM_CONFIG__ALIGNMENT_MODE__SHIFT) |
+                       (3 << SH_MEM_CONFIG__INITIAL_INST_PREFETCH__SHIFT);
+
+               qpd->sh_mem_ape1_limit = 0;
+               qpd->sh_mem_ape1_base = 0;
+       }
+
+       qpd->sh_mem_bases = compute_sh_mem_bases_64bit(pdd);
+
+       pr_debug("sh_mem_bases 0x%X\n", qpd->sh_mem_bases);
+
+       return 0;
+}
+
+static void init_sdma_vm_v12(struct device_queue_manager *dqm, struct queue *q,
+                           struct qcm_process_device *qpd)
+{
+       /* Not needed on SDMAv4 onwards any more */
+       q->properties.sdma_vm_addr = 0;
+}