Commit 5b87245f authored by Amber Lin's avatar Amber Lin Committed by Alex Deucher

drm/amdkfd: Simplify kfd2kgd interface

After amdkfd module is merged into amdgpu, KFD can call amdgpu directly
and no longer needs to use the function pointer. Replace those function
pointers with functions if they are not ASIC dependent.
Signed-off-by: default avatarAmber Lin <Amber.Lin@amd.com>
Acked-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 17288014
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "kfd_priv.h" #include "kfd_priv.h"
#include "kfd_events.h" #include "kfd_events.h"
#include "cik_int.h" #include "cik_int.h"
#include "amdgpu_amdkfd.h"
static bool cik_event_interrupt_isr(struct kfd_dev *dev, static bool cik_event_interrupt_isr(struct kfd_dev *dev,
const uint32_t *ih_ring_entry, const uint32_t *ih_ring_entry,
...@@ -107,7 +108,7 @@ static void cik_event_interrupt_wq(struct kfd_dev *dev, ...@@ -107,7 +108,7 @@ static void cik_event_interrupt_wq(struct kfd_dev *dev,
kfd_process_vm_fault(dev->dqm, pasid); kfd_process_vm_fault(dev->dqm, pasid);
memset(&info, 0, sizeof(info)); memset(&info, 0, sizeof(info));
dev->kfd2kgd->get_vm_fault_info(dev->kgd, &info); amdgpu_amdkfd_gpuvm_get_vm_fault_info(dev->kgd, &info);
if (!info.page_addr && !info.status) if (!info.page_addr && !info.status)
return; return;
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "kfd_priv.h" #include "kfd_priv.h"
#include "kfd_device_queue_manager.h" #include "kfd_device_queue_manager.h"
#include "kfd_dbgmgr.h" #include "kfd_dbgmgr.h"
#include "amdgpu_amdkfd.h"
static long kfd_ioctl(struct file *, unsigned int, unsigned long); static long kfd_ioctl(struct file *, unsigned int, unsigned long);
static int kfd_open(struct inode *, struct file *); static int kfd_open(struct inode *, struct file *);
...@@ -834,8 +835,7 @@ static int kfd_ioctl_get_clock_counters(struct file *filep, ...@@ -834,8 +835,7 @@ static int kfd_ioctl_get_clock_counters(struct file *filep,
dev = kfd_device_by_id(args->gpu_id); dev = kfd_device_by_id(args->gpu_id);
if (dev) if (dev)
/* Reading GPU clock counter from KGD */ /* Reading GPU clock counter from KGD */
args->gpu_clock_counter = args->gpu_clock_counter = get_gpu_clock_counter(dev->kgd);
dev->kfd2kgd->get_gpu_clock_counter(dev->kgd);
else else
/* Node without GPU resource */ /* Node without GPU resource */
args->gpu_clock_counter = 0; args->gpu_clock_counter = 0;
...@@ -1042,7 +1042,7 @@ static int kfd_ioctl_create_event(struct file *filp, struct kfd_process *p, ...@@ -1042,7 +1042,7 @@ static int kfd_ioctl_create_event(struct file *filp, struct kfd_process *p,
} }
mutex_unlock(&p->mutex); mutex_unlock(&p->mutex);
err = kfd->kfd2kgd->map_gtt_bo_to_kernel(kfd->kgd, err = amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel(kfd->kgd,
mem, &kern_addr, &size); mem, &kern_addr, &size);
if (err) { if (err) {
pr_err("Failed to map event page to kernel\n"); pr_err("Failed to map event page to kernel\n");
...@@ -1240,7 +1240,7 @@ bool kfd_dev_is_large_bar(struct kfd_dev *dev) ...@@ -1240,7 +1240,7 @@ bool kfd_dev_is_large_bar(struct kfd_dev *dev)
if (dev->device_info->needs_iommu_device) if (dev->device_info->needs_iommu_device)
return false; return false;
dev->kfd2kgd->get_local_mem_info(dev->kgd, &mem_info); get_local_mem_info(dev->kgd, &mem_info);
if (mem_info.local_mem_size_private == 0 && if (mem_info.local_mem_size_private == 0 &&
mem_info.local_mem_size_public > 0) mem_info.local_mem_size_public > 0)
return true; return true;
...@@ -1281,7 +1281,7 @@ static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep, ...@@ -1281,7 +1281,7 @@ static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep,
goto err_unlock; goto err_unlock;
} }
err = dev->kfd2kgd->alloc_memory_of_gpu( err = amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
dev->kgd, args->va_addr, args->size, dev->kgd, args->va_addr, args->size,
pdd->vm, (struct kgd_mem **) &mem, &offset, pdd->vm, (struct kgd_mem **) &mem, &offset,
flags); flags);
...@@ -1303,7 +1303,7 @@ static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep, ...@@ -1303,7 +1303,7 @@ static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep,
return 0; return 0;
err_free: err_free:
dev->kfd2kgd->free_memory_of_gpu(dev->kgd, (struct kgd_mem *)mem); amdgpu_amdkfd_gpuvm_free_memory_of_gpu(dev->kgd, (struct kgd_mem *)mem);
err_unlock: err_unlock:
mutex_unlock(&p->mutex); mutex_unlock(&p->mutex);
return err; return err;
...@@ -1338,7 +1338,8 @@ static int kfd_ioctl_free_memory_of_gpu(struct file *filep, ...@@ -1338,7 +1338,8 @@ static int kfd_ioctl_free_memory_of_gpu(struct file *filep,
goto err_unlock; goto err_unlock;
} }
ret = dev->kfd2kgd->free_memory_of_gpu(dev->kgd, (struct kgd_mem *)mem); ret = amdgpu_amdkfd_gpuvm_free_memory_of_gpu(dev->kgd,
(struct kgd_mem *)mem);
/* If freeing the buffer failed, leave the handle in place for /* If freeing the buffer failed, leave the handle in place for
* clean-up during process tear-down. * clean-up during process tear-down.
...@@ -1418,7 +1419,7 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep, ...@@ -1418,7 +1419,7 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep,
err = PTR_ERR(peer_pdd); err = PTR_ERR(peer_pdd);
goto get_mem_obj_from_handle_failed; goto get_mem_obj_from_handle_failed;
} }
err = peer->kfd2kgd->map_memory_to_gpu( err = amdgpu_amdkfd_gpuvm_map_memory_to_gpu(
peer->kgd, (struct kgd_mem *)mem, peer_pdd->vm); peer->kgd, (struct kgd_mem *)mem, peer_pdd->vm);
if (err) { if (err) {
pr_err("Failed to map to gpu %d/%d\n", pr_err("Failed to map to gpu %d/%d\n",
...@@ -1430,7 +1431,7 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep, ...@@ -1430,7 +1431,7 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep,
mutex_unlock(&p->mutex); mutex_unlock(&p->mutex);
err = dev->kfd2kgd->sync_memory(dev->kgd, (struct kgd_mem *) mem, true); err = amdgpu_amdkfd_gpuvm_sync_memory(dev->kgd, (struct kgd_mem *) mem, true);
if (err) { if (err) {
pr_debug("Sync memory failed, wait interrupted by user signal\n"); pr_debug("Sync memory failed, wait interrupted by user signal\n");
goto sync_memory_failed; goto sync_memory_failed;
...@@ -1525,7 +1526,7 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep, ...@@ -1525,7 +1526,7 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep,
err = -ENODEV; err = -ENODEV;
goto get_mem_obj_from_handle_failed; goto get_mem_obj_from_handle_failed;
} }
err = dev->kfd2kgd->unmap_memory_to_gpu( err = amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(
peer->kgd, (struct kgd_mem *)mem, peer_pdd->vm); peer->kgd, (struct kgd_mem *)mem, peer_pdd->vm);
if (err) { if (err) {
pr_err("Failed to unmap from gpu %d/%d\n", pr_err("Failed to unmap from gpu %d/%d\n",
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "kfd_priv.h" #include "kfd_priv.h"
#include "kfd_topology.h" #include "kfd_topology.h"
#include "kfd_iommu.h" #include "kfd_iommu.h"
#include "amdgpu_amdkfd.h"
/* GPU Processor ID base for dGPUs for which VCRAT needs to be created. /* GPU Processor ID base for dGPUs for which VCRAT needs to be created.
* GPU processor ID are expressed with Bit[31]=1. * GPU processor ID are expressed with Bit[31]=1.
...@@ -1159,7 +1160,7 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image, ...@@ -1159,7 +1160,7 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image,
cu->flags |= CRAT_CU_FLAGS_GPU_PRESENT; cu->flags |= CRAT_CU_FLAGS_GPU_PRESENT;
cu->proximity_domain = proximity_domain; cu->proximity_domain = proximity_domain;
kdev->kfd2kgd->get_cu_info(kdev->kgd, &cu_info); get_cu_info(kdev->kgd, &cu_info);
cu->num_simd_per_cu = cu_info.simd_per_cu; cu->num_simd_per_cu = cu_info.simd_per_cu;
cu->num_simd_cores = cu_info.simd_per_cu * cu_info.cu_active_number; cu->num_simd_cores = cu_info.simd_per_cu * cu_info.cu_active_number;
cu->max_waves_simd = cu_info.max_waves_per_simd; cu->max_waves_simd = cu_info.max_waves_per_simd;
...@@ -1190,7 +1191,7 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image, ...@@ -1190,7 +1191,7 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image,
* report the total FB size (public+private) as a single * report the total FB size (public+private) as a single
* private heap. * private heap.
*/ */
kdev->kfd2kgd->get_local_mem_info(kdev->kgd, &local_mem_info); get_local_mem_info(kdev->kgd, &local_mem_info);
sub_type_hdr = (typeof(sub_type_hdr))((char *)sub_type_hdr + sub_type_hdr = (typeof(sub_type_hdr))((char *)sub_type_hdr +
sub_type_hdr->length); sub_type_hdr->length);
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "kfd_pm4_headers_vi.h" #include "kfd_pm4_headers_vi.h"
#include "cwsr_trap_handler.h" #include "cwsr_trap_handler.h"
#include "kfd_iommu.h" #include "kfd_iommu.h"
#include "amdgpu_amdkfd.h"
#define MQD_SIZE_ALIGNED 768 #define MQD_SIZE_ALIGNED 768
...@@ -478,7 +479,7 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd, ...@@ -478,7 +479,7 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
/* add another 512KB for all other allocations on gart (HPD, fences) */ /* add another 512KB for all other allocations on gart (HPD, fences) */
size += 512 * 1024; size += 512 * 1024;
if (kfd->kfd2kgd->init_gtt_mem_allocation( if (alloc_gtt_mem(
kfd->kgd, size, &kfd->gtt_mem, kfd->kgd, size, &kfd->gtt_mem,
&kfd->gtt_start_gpu_addr, &kfd->gtt_start_cpu_ptr, &kfd->gtt_start_gpu_addr, &kfd->gtt_start_cpu_ptr,
false)) { false)) {
...@@ -552,7 +553,7 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd, ...@@ -552,7 +553,7 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
kfd_doorbell_error: kfd_doorbell_error:
kfd_gtt_sa_fini(kfd); kfd_gtt_sa_fini(kfd);
kfd_gtt_sa_init_error: kfd_gtt_sa_init_error:
kfd->kfd2kgd->free_gtt_mem(kfd->kgd, kfd->gtt_mem); free_gtt_mem(kfd->kgd, kfd->gtt_mem);
dev_err(kfd_device, dev_err(kfd_device,
"device %x:%x NOT added due to errors\n", "device %x:%x NOT added due to errors\n",
kfd->pdev->vendor, kfd->pdev->device); kfd->pdev->vendor, kfd->pdev->device);
...@@ -569,7 +570,7 @@ void kgd2kfd_device_exit(struct kfd_dev *kfd) ...@@ -569,7 +570,7 @@ void kgd2kfd_device_exit(struct kfd_dev *kfd)
kfd_topology_remove_device(kfd); kfd_topology_remove_device(kfd);
kfd_doorbell_fini(kfd); kfd_doorbell_fini(kfd);
kfd_gtt_sa_fini(kfd); kfd_gtt_sa_fini(kfd);
kfd->kfd2kgd->free_gtt_mem(kfd->kgd, kfd->gtt_mem); free_gtt_mem(kfd->kgd, kfd->gtt_mem);
} }
kfree(kfd); kfree(kfd);
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "kfd_mqd_manager.h" #include "kfd_mqd_manager.h"
#include "cik_regs.h" #include "cik_regs.h"
#include "kfd_kernel_queue.h" #include "kfd_kernel_queue.h"
#include "amdgpu_amdkfd.h"
/* Size of the per-pipe EOP queue */ /* Size of the per-pipe EOP queue */
#define CIK_HPD_EOP_BYTES_LOG2 11 #define CIK_HPD_EOP_BYTES_LOG2 11
...@@ -219,7 +220,7 @@ static int flush_texture_cache_nocpsch(struct kfd_dev *kdev, ...@@ -219,7 +220,7 @@ static int flush_texture_cache_nocpsch(struct kfd_dev *kdev,
if (ret) if (ret)
return ret; return ret;
return kdev->kfd2kgd->submit_ib(kdev->kgd, KGD_ENGINE_MEC1, qpd->vmid, return amdgpu_amdkfd_submit_ib(kdev->kgd, KGD_ENGINE_MEC1, qpd->vmid,
qpd->ib_base, (uint32_t *)qpd->ib_kaddr, qpd->ib_base, (uint32_t *)qpd->ib_kaddr,
pmf->release_mem_size / sizeof(uint32_t)); pmf->release_mem_size / sizeof(uint32_t));
} }
...@@ -672,7 +673,7 @@ static int restore_process_queues_nocpsch(struct device_queue_manager *dqm, ...@@ -672,7 +673,7 @@ static int restore_process_queues_nocpsch(struct device_queue_manager *dqm,
pdd = qpd_to_pdd(qpd); pdd = qpd_to_pdd(qpd);
/* Retrieve PD base */ /* Retrieve PD base */
pd_base = dqm->dev->kfd2kgd->get_process_page_dir(pdd->vm); pd_base = amdgpu_amdkfd_gpuvm_get_process_page_dir(pdd->vm);
dqm_lock(dqm); dqm_lock(dqm);
if (WARN_ON_ONCE(!qpd->evicted)) /* already restored, do nothing */ if (WARN_ON_ONCE(!qpd->evicted)) /* already restored, do nothing */
...@@ -743,7 +744,7 @@ static int restore_process_queues_cpsch(struct device_queue_manager *dqm, ...@@ -743,7 +744,7 @@ static int restore_process_queues_cpsch(struct device_queue_manager *dqm,
pdd = qpd_to_pdd(qpd); pdd = qpd_to_pdd(qpd);
/* Retrieve PD base */ /* Retrieve PD base */
pd_base = dqm->dev->kfd2kgd->get_process_page_dir(pdd->vm); pd_base = amdgpu_amdkfd_gpuvm_get_process_page_dir(pdd->vm);
dqm_lock(dqm); dqm_lock(dqm);
if (WARN_ON_ONCE(!qpd->evicted)) /* already restored, do nothing */ if (WARN_ON_ONCE(!qpd->evicted)) /* already restored, do nothing */
...@@ -793,7 +794,7 @@ static int register_process(struct device_queue_manager *dqm, ...@@ -793,7 +794,7 @@ static int register_process(struct device_queue_manager *dqm,
pdd = qpd_to_pdd(qpd); pdd = qpd_to_pdd(qpd);
/* Retrieve PD base */ /* Retrieve PD base */
pd_base = dqm->dev->kfd2kgd->get_process_page_dir(pdd->vm); pd_base = amdgpu_amdkfd_gpuvm_get_process_page_dir(pdd->vm);
dqm_lock(dqm); dqm_lock(dqm);
list_add(&n->list, &dqm->queues); list_add(&n->list, &dqm->queues);
...@@ -805,7 +806,7 @@ static int register_process(struct device_queue_manager *dqm, ...@@ -805,7 +806,7 @@ static int register_process(struct device_queue_manager *dqm,
retval = dqm->asic_ops.update_qpd(dqm, qpd); retval = dqm->asic_ops.update_qpd(dqm, qpd);
if (dqm->processes_count++ == 0) if (dqm->processes_count++ == 0)
dqm->dev->kfd2kgd->set_compute_idle(dqm->dev->kgd, false); amdgpu_amdkfd_set_compute_idle(dqm->dev->kgd, false);
dqm_unlock(dqm); dqm_unlock(dqm);
...@@ -829,7 +830,7 @@ static int unregister_process(struct device_queue_manager *dqm, ...@@ -829,7 +830,7 @@ static int unregister_process(struct device_queue_manager *dqm,
list_del(&cur->list); list_del(&cur->list);
kfree(cur); kfree(cur);
if (--dqm->processes_count == 0) if (--dqm->processes_count == 0)
dqm->dev->kfd2kgd->set_compute_idle( amdgpu_amdkfd_set_compute_idle(
dqm->dev->kgd, true); dqm->dev->kgd, true);
goto out; goto out;
} }
...@@ -1796,7 +1797,7 @@ static void kfd_process_hw_exception(struct work_struct *work) ...@@ -1796,7 +1797,7 @@ static void kfd_process_hw_exception(struct work_struct *work)
{ {
struct device_queue_manager *dqm = container_of(work, struct device_queue_manager *dqm = container_of(work,
struct device_queue_manager, hw_exception_work); struct device_queue_manager, hw_exception_work);
dqm->dev->kfd2kgd->gpu_recover(dqm->dev->kgd); amdgpu_amdkfd_gpu_reset(dqm->dev->kgd);
} }
#if defined(CONFIG_DEBUG_FS) #if defined(CONFIG_DEBUG_FS)
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
*/ */
#include "kfd_mqd_manager.h" #include "kfd_mqd_manager.h"
#include "amdgpu_amdkfd.h"
struct mqd_manager *mqd_manager_init(enum KFD_MQD_TYPE type, struct mqd_manager *mqd_manager_init(enum KFD_MQD_TYPE type,
struct kfd_dev *dev) struct kfd_dev *dev)
...@@ -58,7 +59,7 @@ void mqd_symmetrically_map_cu_mask(struct mqd_manager *mm, ...@@ -58,7 +59,7 @@ void mqd_symmetrically_map_cu_mask(struct mqd_manager *mm,
uint32_t cu_per_sh[4] = {0}; uint32_t cu_per_sh[4] = {0};
int i, se, cu = 0; int i, se, cu = 0;
mm->dev->kfd2kgd->get_cu_info(mm->dev->kgd, &cu_info); get_cu_info(mm->dev->kgd, &cu_info);
if (cu_mask_count > cu_info.cu_active_number) if (cu_mask_count > cu_info.cu_active_number)
cu_mask_count = cu_info.cu_active_number; cu_mask_count = cu_info.cu_active_number;
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "gc/gc_9_0_offset.h" #include "gc/gc_9_0_offset.h"
#include "gc/gc_9_0_sh_mask.h" #include "gc/gc_9_0_sh_mask.h"
#include "sdma0/sdma0_4_0_sh_mask.h" #include "sdma0/sdma0_4_0_sh_mask.h"
#include "amdgpu_amdkfd.h"
static inline struct v9_mqd *get_mqd(void *mqd) static inline struct v9_mqd *get_mqd(void *mqd)
{ {
...@@ -83,7 +84,7 @@ static int init_mqd(struct mqd_manager *mm, void **mqd, ...@@ -83,7 +84,7 @@ static int init_mqd(struct mqd_manager *mm, void **mqd,
*mqd_mem_obj = kzalloc(sizeof(struct kfd_mem_obj), GFP_KERNEL); *mqd_mem_obj = kzalloc(sizeof(struct kfd_mem_obj), GFP_KERNEL);
if (!*mqd_mem_obj) if (!*mqd_mem_obj)
return -ENOMEM; return -ENOMEM;
retval = kfd->kfd2kgd->init_gtt_mem_allocation(kfd->kgd, retval = alloc_gtt_mem(kfd->kgd,
ALIGN(q->ctl_stack_size, PAGE_SIZE) + ALIGN(q->ctl_stack_size, PAGE_SIZE) +
ALIGN(sizeof(struct v9_mqd), PAGE_SIZE), ALIGN(sizeof(struct v9_mqd), PAGE_SIZE),
&((*mqd_mem_obj)->gtt_mem), &((*mqd_mem_obj)->gtt_mem),
...@@ -250,7 +251,7 @@ static void uninit_mqd(struct mqd_manager *mm, void *mqd, ...@@ -250,7 +251,7 @@ static void uninit_mqd(struct mqd_manager *mm, void *mqd,
struct kfd_dev *kfd = mm->dev; struct kfd_dev *kfd = mm->dev;
if (mqd_mem_obj->gtt_mem) { if (mqd_mem_obj->gtt_mem) {
kfd->kfd2kgd->free_gtt_mem(kfd->kgd, mqd_mem_obj->gtt_mem); free_gtt_mem(kfd->kgd, mqd_mem_obj->gtt_mem);
kfree(mqd_mem_obj); kfree(mqd_mem_obj);
} else { } else {
kfd_gtt_sa_free(mm->dev, mqd_mem_obj); kfd_gtt_sa_free(mm->dev, mqd_mem_obj);
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/types.h> #include <linux/types.h>
#include "kfd_priv.h" #include "kfd_priv.h"
#include "amdgpu_ids.h"
static unsigned int pasid_bits = 16; static unsigned int pasid_bits = 16;
static const struct kfd2kgd_calls *kfd2kgd; static const struct kfd2kgd_calls *kfd2kgd;
...@@ -71,7 +72,7 @@ unsigned int kfd_pasid_alloc(void) ...@@ -71,7 +72,7 @@ unsigned int kfd_pasid_alloc(void)
return false; return false;
} }
r = kfd2kgd->alloc_pasid(pasid_bits); r = amdgpu_pasid_alloc(pasid_bits);
return r > 0 ? r : 0; return r > 0 ? r : 0;
} }
...@@ -79,5 +80,5 @@ unsigned int kfd_pasid_alloc(void) ...@@ -79,5 +80,5 @@ unsigned int kfd_pasid_alloc(void)
void kfd_pasid_free(unsigned int pasid) void kfd_pasid_free(unsigned int pasid)
{ {
if (kfd2kgd) if (kfd2kgd)
kfd2kgd->free_pasid(pasid); amdgpu_pasid_free(pasid);
} }
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <linux/compat.h> #include <linux/compat.h>
#include <linux/mman.h> #include <linux/mman.h>
#include <linux/file.h> #include <linux/file.h>
#include "amdgpu_amdkfd.h"
struct mm_struct; struct mm_struct;
...@@ -100,8 +101,8 @@ static void kfd_process_free_gpuvm(struct kgd_mem *mem, ...@@ -100,8 +101,8 @@ static void kfd_process_free_gpuvm(struct kgd_mem *mem,
{ {
struct kfd_dev *dev = pdd->dev; struct kfd_dev *dev = pdd->dev;
dev->kfd2kgd->unmap_memory_to_gpu(dev->kgd, mem, pdd->vm); amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(dev->kgd, mem, pdd->vm);
dev->kfd2kgd->free_memory_of_gpu(dev->kgd, mem); amdgpu_amdkfd_gpuvm_free_memory_of_gpu(dev->kgd, mem);
} }
/* kfd_process_alloc_gpuvm - Allocate GPU VM for the KFD process /* kfd_process_alloc_gpuvm - Allocate GPU VM for the KFD process
...@@ -119,16 +120,16 @@ static int kfd_process_alloc_gpuvm(struct kfd_process_device *pdd, ...@@ -119,16 +120,16 @@ static int kfd_process_alloc_gpuvm(struct kfd_process_device *pdd,
int handle; int handle;
int err; int err;
err = kdev->kfd2kgd->alloc_memory_of_gpu(kdev->kgd, gpu_va, size, err = amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(kdev->kgd, gpu_va, size,
pdd->vm, &mem, NULL, flags); pdd->vm, &mem, NULL, flags);
if (err) if (err)
goto err_alloc_mem; goto err_alloc_mem;
err = kdev->kfd2kgd->map_memory_to_gpu(kdev->kgd, mem, pdd->vm); err = amdgpu_amdkfd_gpuvm_map_memory_to_gpu(kdev->kgd, mem, pdd->vm);
if (err) if (err)
goto err_map_mem; goto err_map_mem;
err = kdev->kfd2kgd->sync_memory(kdev->kgd, mem, true); err = amdgpu_amdkfd_gpuvm_sync_memory(kdev->kgd, mem, true);
if (err) { if (err) {
pr_debug("Sync memory failed, wait interrupted by user signal\n"); pr_debug("Sync memory failed, wait interrupted by user signal\n");
goto sync_memory_failed; goto sync_memory_failed;
...@@ -147,7 +148,7 @@ static int kfd_process_alloc_gpuvm(struct kfd_process_device *pdd, ...@@ -147,7 +148,7 @@ static int kfd_process_alloc_gpuvm(struct kfd_process_device *pdd,
} }
if (kptr) { if (kptr) {
err = kdev->kfd2kgd->map_gtt_bo_to_kernel(kdev->kgd, err = amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel(kdev->kgd,
(struct kgd_mem *)mem, kptr, NULL); (struct kgd_mem *)mem, kptr, NULL);
if (err) { if (err) {
pr_debug("Map GTT BO to kernel failed\n"); pr_debug("Map GTT BO to kernel failed\n");
...@@ -165,7 +166,7 @@ static int kfd_process_alloc_gpuvm(struct kfd_process_device *pdd, ...@@ -165,7 +166,7 @@ static int kfd_process_alloc_gpuvm(struct kfd_process_device *pdd,
return err; return err;
err_map_mem: err_map_mem:
kdev->kfd2kgd->free_memory_of_gpu(kdev->kgd, mem); amdgpu_amdkfd_gpuvm_free_memory_of_gpu(kdev->kgd, mem);
err_alloc_mem: err_alloc_mem:
*kptr = NULL; *kptr = NULL;
return err; return err;
...@@ -296,11 +297,11 @@ static void kfd_process_device_free_bos(struct kfd_process_device *pdd) ...@@ -296,11 +297,11 @@ static void kfd_process_device_free_bos(struct kfd_process_device *pdd)
per_device_list) { per_device_list) {
if (!peer_pdd->vm) if (!peer_pdd->vm)
continue; continue;
peer_pdd->dev->kfd2kgd->unmap_memory_to_gpu( amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(
peer_pdd->dev->kgd, mem, peer_pdd->vm); peer_pdd->dev->kgd, mem, peer_pdd->vm);
} }
pdd->dev->kfd2kgd->free_memory_of_gpu(pdd->dev->kgd, mem); amdgpu_amdkfd_gpuvm_free_memory_of_gpu(pdd->dev->kgd, mem);
kfd_process_device_remove_obj_handle(pdd, id); kfd_process_device_remove_obj_handle(pdd, id);
} }
} }
...@@ -323,11 +324,12 @@ static void kfd_process_destroy_pdds(struct kfd_process *p) ...@@ -323,11 +324,12 @@ static void kfd_process_destroy_pdds(struct kfd_process *p)
pdd->dev->id, p->pasid); pdd->dev->id, p->pasid);
if (pdd->drm_file) { if (pdd->drm_file) {
pdd->dev->kfd2kgd->release_process_vm(pdd->dev->kgd, pdd->vm); amdgpu_amdkfd_gpuvm_release_process_vm(
pdd->dev->kgd, pdd->vm);
fput(pdd->drm_file); fput(pdd->drm_file);
} }
else if (pdd->vm) else if (pdd->vm)
pdd->dev->kfd2kgd->destroy_process_vm( amdgpu_amdkfd_gpuvm_destroy_process_vm(
pdd->dev->kgd, pdd->vm); pdd->dev->kgd, pdd->vm);
list_del(&pdd->per_device_list); list_del(&pdd->per_device_list);
...@@ -688,12 +690,12 @@ int kfd_process_device_init_vm(struct kfd_process_device *pdd, ...@@ -688,12 +690,12 @@ int kfd_process_device_init_vm(struct kfd_process_device *pdd,
dev = pdd->dev; dev = pdd->dev;
if (drm_file) if (drm_file)
ret = dev->kfd2kgd->acquire_process_vm( ret = amdgpu_amdkfd_gpuvm_acquire_process_vm(
dev->kgd, drm_file, p->pasid, dev->kgd, drm_file, p->pasid,
&pdd->vm, &p->kgd_process_info, &p->ef); &pdd->vm, &p->kgd_process_info, &p->ef);
else else
ret = dev->kfd2kgd->create_process_vm( ret = amdgpu_amdkfd_gpuvm_create_process_vm(dev->kgd, p->pasid,
dev->kgd, p->pasid, &pdd->vm, &p->kgd_process_info, &p->ef); &pdd->vm, &p->kgd_process_info, &p->ef);
if (ret) { if (ret) {
pr_err("Failed to create process VM object\n"); pr_err("Failed to create process VM object\n");
return ret; return ret;
...@@ -714,7 +716,7 @@ int kfd_process_device_init_vm(struct kfd_process_device *pdd, ...@@ -714,7 +716,7 @@ int kfd_process_device_init_vm(struct kfd_process_device *pdd,
err_reserve_ib_mem: err_reserve_ib_mem:
kfd_process_device_free_bos(pdd); kfd_process_device_free_bos(pdd);
if (!drm_file) if (!drm_file)
dev->kfd2kgd->destroy_process_vm(dev->kgd, pdd->vm); amdgpu_amdkfd_gpuvm_destroy_process_vm(dev->kgd, pdd->vm);
pdd->vm = NULL; pdd->vm = NULL;
return ret; return ret;
...@@ -972,7 +974,7 @@ static void restore_process_worker(struct work_struct *work) ...@@ -972,7 +974,7 @@ static void restore_process_worker(struct work_struct *work)
*/ */
p->last_restore_timestamp = get_jiffies_64(); p->last_restore_timestamp = get_jiffies_64();
ret = pdd->dev->kfd2kgd->restore_process_bos(p->kgd_process_info, ret = amdgpu_amdkfd_gpuvm_restore_process_bos(p->kgd_process_info,
&p->ef); &p->ef);
if (ret) { if (ret) {
pr_debug("Failed to restore BOs of pasid %d, retry after %d ms\n", pr_debug("Failed to restore BOs of pasid %d, retry after %d ms\n",
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "kfd_topology.h" #include "kfd_topology.h"
#include "kfd_device_queue_manager.h" #include "kfd_device_queue_manager.h"
#include "kfd_iommu.h" #include "kfd_iommu.h"
#include "amdgpu_amdkfd.h"
/* topology_device_list - Master list of all topology devices */ /* topology_device_list - Master list of all topology devices */
static struct list_head topology_device_list; static struct list_head topology_device_list;
...@@ -1052,7 +1053,7 @@ static uint32_t kfd_generate_gpu_id(struct kfd_dev *gpu) ...@@ -1052,7 +1053,7 @@ static uint32_t kfd_generate_gpu_id(struct kfd_dev *gpu)
if (!gpu) if (!gpu)
return 0; return 0;
gpu->kfd2kgd->get_local_mem_info(gpu->kgd, &local_mem_info); get_local_mem_info(gpu->kgd, &local_mem_info);
local_mem_size = local_mem_info.local_mem_size_private + local_mem_size = local_mem_info.local_mem_size_private +
local_mem_info.local_mem_size_public; local_mem_info.local_mem_size_public;
...@@ -1118,8 +1119,7 @@ static void kfd_fill_mem_clk_max_info(struct kfd_topology_device *dev) ...@@ -1118,8 +1119,7 @@ static void kfd_fill_mem_clk_max_info(struct kfd_topology_device *dev)
* for APUs - If CRAT from ACPI reports more than one bank, then * for APUs - If CRAT from ACPI reports more than one bank, then
* all the banks will report the same mem_clk_max information * all the banks will report the same mem_clk_max information
*/ */
dev->gpu->kfd2kgd->get_local_mem_info(dev->gpu->kgd, get_local_mem_info(dev->gpu->kgd, &local_mem_info);
&local_mem_info);
list_for_each_entry(mem, &dev->mem_props, list) list_for_each_entry(mem, &dev->mem_props, list)
mem->mem_clk_max = local_mem_info.mem_clk_max; mem->mem_clk_max = local_mem_info.mem_clk_max;
...@@ -1240,7 +1240,7 @@ int kfd_topology_add_device(struct kfd_dev *gpu) ...@@ -1240,7 +1240,7 @@ int kfd_topology_add_device(struct kfd_dev *gpu)
* needed for the topology * needed for the topology
*/ */
dev->gpu->kfd2kgd->get_cu_info(dev->gpu->kgd, &cu_info); get_cu_info(dev->gpu->kgd, &cu_info);
dev->node_props.simd_arrays_per_engine = dev->node_props.simd_arrays_per_engine =
cu_info.num_shader_arrays_per_engine; cu_info.num_shader_arrays_per_engine;
...@@ -1249,7 +1249,7 @@ int kfd_topology_add_device(struct kfd_dev *gpu) ...@@ -1249,7 +1249,7 @@ int kfd_topology_add_device(struct kfd_dev *gpu)
dev->node_props.location_id = PCI_DEVID(gpu->pdev->bus->number, dev->node_props.location_id = PCI_DEVID(gpu->pdev->bus->number,
gpu->pdev->devfn); gpu->pdev->devfn);
dev->node_props.max_engine_clk_fcompute = dev->node_props.max_engine_clk_fcompute =
dev->gpu->kfd2kgd->get_max_engine_clock_in_mhz(dev->gpu->kgd); get_max_engine_clock_in_mhz(dev->gpu->kgd);
dev->node_props.max_engine_clk_ccompute = dev->node_props.max_engine_clk_ccompute =
cpufreq_quick_get_max(0) / 1000; cpufreq_quick_get_max(0) / 1000;
dev->node_props.drm_render_minor = dev->node_props.drm_render_minor =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment