]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/amdkfd: Add GFXv9 device queue manager
authorFelix Kuehling <Felix.Kuehling@amd.com>
Tue, 10 Apr 2018 21:33:09 +0000 (17:33 -0400)
committerOded Gabbay <oded.gabbay@gmail.com>
Tue, 10 Apr 2018 21:33:09 +0000 (17:33 -0400)
Signed-off-by: John Bridgman <john.bridgman@amd.com>
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.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_v9.c [new file with mode: 0644]
drivers/gpu/drm/amd/amdkfd/kfd_module.c
drivers/gpu/drm/amd/amdkfd/kfd_priv.h

index 094b591ed8c20b840292f0deb044d3886ed64a1b..ff8b5aa11f4e1472295637180c9389323e8ba3ab 100644 (file)
@@ -35,7 +35,7 @@ amdkfd-y      := kfd_module.o kfd_device.o kfd_chardev.o kfd_topology.o \
                kfd_kernel_queue_vi.o kfd_kernel_queue_v9.o \
                kfd_packet_manager.o kfd_process_queue_manager.o \
                kfd_device_queue_manager.o kfd_device_queue_manager_cik.o \
-               kfd_device_queue_manager_vi.o \
+               kfd_device_queue_manager_vi.o kfd_device_queue_manager_v9.o \
                kfd_interrupt.o kfd_events.o cik_event_interrupt.o \
                kfd_dbgdev.o kfd_dbgmgr.o kfd_crat.o
 
index 500f022d089d17a6be1a3bd57e7e58e2fb11b373..9af94b1f9074eea230ab7bc808f8769c661101bf 100644 (file)
@@ -1386,7 +1386,10 @@ static bool set_cache_memory_policy(struct device_queue_manager *dqm,
                                   void __user *alternate_aperture_base,
                                   uint64_t alternate_aperture_size)
 {
-       bool retval;
+       bool retval = true;
+
+       if (!dqm->asic_ops.set_cache_memory_policy)
+               return retval;
 
        mutex_lock(&dqm->lock);
 
@@ -1655,6 +1658,11 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev)
        case CHIP_POLARIS11:
                device_queue_manager_init_vi_tonga(&dqm->asic_ops);
                break;
+
+       case CHIP_VEGA10:
+       case CHIP_RAVEN:
+               device_queue_manager_init_v9(&dqm->asic_ops);
+               break;
        default:
                WARN(1, "Unexpected ASIC family %u",
                     dev->device_info->asic_family);
index 412beff3281da71062250149017389f7535ded8a..59a6b1956932ffa160915f869f4e3f6222fc0f89 100644 (file)
@@ -200,6 +200,8 @@ void device_queue_manager_init_vi(
                struct device_queue_manager_asic_ops *asic_ops);
 void device_queue_manager_init_vi_tonga(
                struct device_queue_manager_asic_ops *asic_ops);
+void device_queue_manager_init_v9(
+               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_queues_num(struct device_queue_manager *dqm);
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v9.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v9.c
new file mode 100644 (file)
index 0000000..79e5bcf
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2016-2018 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 "vega10_enum.h"
+#include "gc/gc_9_0_offset.h"
+#include "gc/gc_9_0_sh_mask.h"
+#include "sdma0/sdma0_4_0_sh_mask.h"
+
+static int update_qpd_v9(struct device_queue_manager *dqm,
+                        struct qcm_process_device *qpd);
+static void init_sdma_vm_v9(struct device_queue_manager *dqm, struct queue *q,
+                           struct qcm_process_device *qpd);
+
+void device_queue_manager_init_v9(
+       struct device_queue_manager_asic_ops *asic_ops)
+{
+       asic_ops->update_qpd = update_qpd_v9;
+       asic_ops->init_sdma_vm = init_sdma_vm_v9;
+}
+
+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_v9(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;
+               if (vega10_noretry &&
+                   !dqm->dev->device_info->needs_iommu_device)
+                       qpd->sh_mem_config |=
+                               1 << SH_MEM_CONFIG__RETRY_DISABLE__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_v9(struct device_queue_manager *dqm, struct queue *q,
+                           struct qcm_process_device *qpd)
+{
+       /* Not needed on SDMAv4 any more */
+       q->properties.sdma_vm_addr = 0;
+}
index 45bc458f7348702083074bc9459e41e345004572..76bf2dc8aec4398afcf5b5835650e445b528cabe 100644 (file)
@@ -83,6 +83,11 @@ module_param(ignore_crat, int, 0444);
 MODULE_PARM_DESC(ignore_crat,
        "Ignore CRAT table during KFD initialization (0 = use CRAT (default), 1 = ignore CRAT)");
 
+int vega10_noretry;
+module_param_named(noretry, vega10_noretry, int, 0644);
+MODULE_PARM_DESC(noretry,
+       "Set sh_mem_config.retry_disable on Vega10 (0 = retry enabled (default), 1 = retry disabled)");
+
 static int amdkfd_init_completed;
 
 int kgd2kfd_init(unsigned int interface_version,
index fac28827b00086cb0af564060274eae778ad895a..d5cdb5db498330e9ee7948f38486d28ab1ff23d9 100644 (file)
@@ -137,6 +137,11 @@ extern int debug_largebar;
  */
 extern int ignore_crat;
 
+/*
+ * Set sh_mem_config.retry_disable on Vega10
+ */
+extern int vega10_noretry;
+
 /**
  * enum kfd_sched_policy
  *