drm/amdgpu: Add kgd/kfd interface to support scratch memory v2
authorMoses Reuben <moses.reuben@amd.com>
Wed, 16 Aug 2017 03:00:19 +0000 (23:00 -0400)
committerOded Gabbay <oded.gabbay@gmail.com>
Wed, 16 Aug 2017 03:00:19 +0000 (23:00 -0400)
v2:
* Shortened headline
* Removed write_config_static_mem, it gets initialized by gfx_v?_0_gpu_init
* Renamed alloc_memory_of_scratch to set_scratch_backing_va
* Made set_scratch_backing_va a void function
* Documented set_scratch_backing in kgd_kfd_interface.h

Signed-off-by: Moses Reuben <moses.reuben@amd.com>
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c
drivers/gpu/drm/amd/include/kgd_kfd_interface.h

index d1719becb4df22f1042716b493215b34d98f0324..3793d7b1d2ec4be071da6a86077ed53ea962438b 100644 (file)
@@ -135,6 +135,8 @@ static uint16_t get_atc_vmid_pasid_mapping_pasid(struct kgd_dev *kgd,
 static void write_vmid_invalidate_request(struct kgd_dev *kgd, uint8_t vmid);
 
 static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type);
+static void set_scratch_backing_va(struct kgd_dev *kgd,
+                                       uint64_t va, uint32_t vmid);
 
 static const struct kfd2kgd_calls kfd2kgd = {
        .init_gtt_mem_allocation = alloc_gtt_mem,
@@ -159,7 +161,8 @@ static const struct kfd2kgd_calls kfd2kgd = {
        .get_atc_vmid_pasid_mapping_pasid = get_atc_vmid_pasid_mapping_pasid,
        .get_atc_vmid_pasid_mapping_valid = get_atc_vmid_pasid_mapping_valid,
        .write_vmid_invalidate_request = write_vmid_invalidate_request,
-       .get_fw_version = get_fw_version
+       .get_fw_version = get_fw_version,
+       .set_scratch_backing_va = set_scratch_backing_va,
 };
 
 struct kfd2kgd_calls *amdgpu_amdkfd_gfx_7_get_functions(void)
@@ -652,6 +655,16 @@ static void write_vmid_invalidate_request(struct kgd_dev *kgd, uint8_t vmid)
        WREG32(mmVM_INVALIDATE_REQUEST, 1 << vmid);
 }
 
+static void set_scratch_backing_va(struct kgd_dev *kgd,
+                                       uint64_t va, uint32_t vmid)
+{
+       struct amdgpu_device *adev = (struct amdgpu_device *) kgd;
+
+       lock_srbm(kgd, 0, 0, 0, vmid);
+       WREG32(mmSH_HIDDEN_PRIVATE_BASE_VMID, va);
+       unlock_srbm(kgd);
+}
+
 static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type)
 {
        struct amdgpu_device *adev = (struct amdgpu_device *) kgd;
index 29a6f5d9de8eb422d6486c167710fca28fdcf67b..61f6457a68977fba84367b3da7675ef314b5a6e2 100644 (file)
@@ -94,6 +94,8 @@ static uint16_t get_atc_vmid_pasid_mapping_pasid(struct kgd_dev *kgd,
                uint8_t vmid);
 static void write_vmid_invalidate_request(struct kgd_dev *kgd, uint8_t vmid);
 static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type);
+static void set_scratch_backing_va(struct kgd_dev *kgd,
+                                       uint64_t va, uint32_t vmid);
 
 static const struct kfd2kgd_calls kfd2kgd = {
        .init_gtt_mem_allocation = alloc_gtt_mem,
@@ -120,12 +122,14 @@ static const struct kfd2kgd_calls kfd2kgd = {
        .get_atc_vmid_pasid_mapping_valid =
                        get_atc_vmid_pasid_mapping_valid,
        .write_vmid_invalidate_request = write_vmid_invalidate_request,
-       .get_fw_version = get_fw_version
+       .get_fw_version = get_fw_version,
+       .set_scratch_backing_va = set_scratch_backing_va,
 };
 
 struct kfd2kgd_calls *amdgpu_amdkfd_gfx_8_0_get_functions(void)
 {
        return (struct kfd2kgd_calls *)&kfd2kgd;
+       return (struct kfd2kgd_calls *)&kfd2kgd;
 }
 
 static inline struct amdgpu_device *get_amdgpu_device(struct kgd_dev *kgd)
@@ -573,6 +577,16 @@ static uint32_t kgd_address_watch_get_offset(struct kgd_dev *kgd,
        return 0;
 }
 
+static void set_scratch_backing_va(struct kgd_dev *kgd,
+                                       uint64_t va, uint32_t vmid)
+{
+       struct amdgpu_device *adev = (struct amdgpu_device *) kgd;
+
+       lock_srbm(kgd, 0, 0, 0, vmid);
+       WREG32(mmSH_HIDDEN_PRIVATE_BASE_VMID, va);
+       unlock_srbm(kgd);
+}
+
 static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type)
 {
        struct amdgpu_device *adev = (struct amdgpu_device *) kgd;
index ffafda0ec620ad046b050c961987d03efbc782ed..2a9cc5edb0ad00e4ec153ee2e2a9b15f6ff62f4a 100644 (file)
@@ -128,6 +128,9 @@ struct kgd2kfd_shared_resources {
  *
  * @get_fw_version: Returns FW versions from the header
  *
+ * @set_scratch_backing_va: Sets VA for scratch backing memory of a VMID.
+ * Only used for no cp scheduling mode
+ *
  * This structure contains function pointers to services that the kgd driver
  * provides to amdkfd driver.
  *
@@ -199,6 +202,8 @@ struct kfd2kgd_calls {
 
        uint16_t (*get_fw_version)(struct kgd_dev *kgd,
                                enum kgd_engine_type type);
+       void (*set_scratch_backing_va)(struct kgd_dev *kgd,
+                               uint64_t va, uint32_t vmid);
 };
 
 /**