Commit dff63da9 authored by Graham Sider's avatar Graham Sider Committed by Alex Deucher

drm/amdkfd: replace kgd_dev in gpuvm amdgpu_amdkfd funcs

Modified definitions:

- amdgpu_amdkfd_gpuvm_acquire_process_vm
- amdgpu_amdkfd_gpuvm_release_process_vm
- amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu
- amdgpu_amdkfd_gpuvm_free_memory_of_gpu
- amdgpu_amdkfd_gpuvm_map_memory_to_gpu
- amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu
- amdgpu_amdkfd_gpuvm_sync_memory
- amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel
- amdgpu_amdkfd_gpuvm_unmap_gtt_bo_from_kernel
- amdgpu_amdkfd_gpuvm_get_vm_fault_info
- amdgpu_amdkfd_gpuvm_import_dmabuf
- amdgpu_amdkfd_get_tile_config

Removed:

- get_amdgpu_device
Signed-off-by: default avatarGraham Sider <Graham.Sider@amd.com>
Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 574c4183
...@@ -265,39 +265,42 @@ int amdgpu_amdkfd_get_pcie_bandwidth_mbytes(struct amdgpu_device *adev, bool is_ ...@@ -265,39 +265,42 @@ int amdgpu_amdkfd_get_pcie_bandwidth_mbytes(struct amdgpu_device *adev, bool is_
(&((struct amdgpu_fpriv *) \ (&((struct amdgpu_fpriv *) \
((struct drm_file *)(drm_priv))->driver_priv)->vm) ((struct drm_file *)(drm_priv))->driver_priv)->vm)
int amdgpu_amdkfd_gpuvm_acquire_process_vm(struct kgd_dev *kgd, int amdgpu_amdkfd_gpuvm_acquire_process_vm(struct amdgpu_device *adev,
struct file *filp, u32 pasid, struct file *filp, u32 pasid,
void **process_info, void **process_info,
struct dma_fence **ef); struct dma_fence **ef);
void amdgpu_amdkfd_gpuvm_release_process_vm(struct kgd_dev *kgd, void *drm_priv); void amdgpu_amdkfd_gpuvm_release_process_vm(struct amdgpu_device *adev,
void *drm_priv);
uint64_t amdgpu_amdkfd_gpuvm_get_process_page_dir(void *drm_priv); uint64_t amdgpu_amdkfd_gpuvm_get_process_page_dir(void *drm_priv);
int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
struct kgd_dev *kgd, uint64_t va, uint64_t size, struct amdgpu_device *adev, uint64_t va, uint64_t size,
void *drm_priv, struct kgd_mem **mem, void *drm_priv, struct kgd_mem **mem,
uint64_t *offset, uint32_t flags); uint64_t *offset, uint32_t flags);
int amdgpu_amdkfd_gpuvm_free_memory_of_gpu( int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
struct kgd_dev *kgd, struct kgd_mem *mem, void *drm_priv, struct amdgpu_device *adev, struct kgd_mem *mem, void *drm_priv,
uint64_t *size); uint64_t *size);
int amdgpu_amdkfd_gpuvm_map_memory_to_gpu( int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(
struct kgd_dev *kgd, struct kgd_mem *mem, void *drm_priv, bool *table_freed); struct amdgpu_device *adev, struct kgd_mem *mem, void *drm_priv,
bool *table_freed);
int amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu( int amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(
struct kgd_dev *kgd, struct kgd_mem *mem, void *drm_priv); struct amdgpu_device *adev, struct kgd_mem *mem, void *drm_priv);
int amdgpu_amdkfd_gpuvm_sync_memory( int amdgpu_amdkfd_gpuvm_sync_memory(
struct kgd_dev *kgd, struct kgd_mem *mem, bool intr); struct amdgpu_device *adev, struct kgd_mem *mem, bool intr);
int amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel(struct kgd_dev *kgd, int amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel(struct amdgpu_device *adev,
struct kgd_mem *mem, void **kptr, uint64_t *size); struct kgd_mem *mem, void **kptr, uint64_t *size);
void amdgpu_amdkfd_gpuvm_unmap_gtt_bo_from_kernel(struct kgd_dev *kgd, struct kgd_mem *mem); void amdgpu_amdkfd_gpuvm_unmap_gtt_bo_from_kernel(struct amdgpu_device *adev,
struct kgd_mem *mem);
int amdgpu_amdkfd_gpuvm_restore_process_bos(void *process_info, int amdgpu_amdkfd_gpuvm_restore_process_bos(void *process_info,
struct dma_fence **ef); struct dma_fence **ef);
int amdgpu_amdkfd_gpuvm_get_vm_fault_info(struct kgd_dev *kgd, int amdgpu_amdkfd_gpuvm_get_vm_fault_info(struct amdgpu_device *adev,
struct kfd_vm_fault_info *info); struct kfd_vm_fault_info *info);
int amdgpu_amdkfd_gpuvm_import_dmabuf(struct kgd_dev *kgd, int amdgpu_amdkfd_gpuvm_import_dmabuf(struct amdgpu_device *adev,
struct dma_buf *dmabuf, struct dma_buf *dmabuf,
uint64_t va, void *drm_priv, uint64_t va, void *drm_priv,
struct kgd_mem **mem, uint64_t *size, struct kgd_mem **mem, uint64_t *size,
uint64_t *mmap_offset); uint64_t *mmap_offset);
int amdgpu_amdkfd_get_tile_config(struct kgd_dev *kgd, int amdgpu_amdkfd_get_tile_config(struct amdgpu_device *adev,
struct tile_config *config); struct tile_config *config);
void amdgpu_amdkfd_ras_poison_consumption_handler(struct amdgpu_device *adev); void amdgpu_amdkfd_ras_poison_consumption_handler(struct amdgpu_device *adev);
#if IS_ENABLED(CONFIG_HSA_AMD) #if IS_ENABLED(CONFIG_HSA_AMD)
......
...@@ -60,12 +60,6 @@ static const char * const domain_bit_to_string[] = { ...@@ -60,12 +60,6 @@ static const char * const domain_bit_to_string[] = {
static void amdgpu_amdkfd_restore_userptr_worker(struct work_struct *work); static void amdgpu_amdkfd_restore_userptr_worker(struct work_struct *work);
static inline struct amdgpu_device *get_amdgpu_device(struct kgd_dev *kgd)
{
return (struct amdgpu_device *)kgd;
}
static bool kfd_mem_is_attached(struct amdgpu_vm *avm, static bool kfd_mem_is_attached(struct amdgpu_vm *avm,
struct kgd_mem *mem) struct kgd_mem *mem)
{ {
...@@ -1278,12 +1272,11 @@ static int init_kfd_vm(struct amdgpu_vm *vm, void **process_info, ...@@ -1278,12 +1272,11 @@ static int init_kfd_vm(struct amdgpu_vm *vm, void **process_info,
return ret; return ret;
} }
int amdgpu_amdkfd_gpuvm_acquire_process_vm(struct kgd_dev *kgd, int amdgpu_amdkfd_gpuvm_acquire_process_vm(struct amdgpu_device *adev,
struct file *filp, u32 pasid, struct file *filp, u32 pasid,
void **process_info, void **process_info,
struct dma_fence **ef) struct dma_fence **ef)
{ {
struct amdgpu_device *adev = get_amdgpu_device(kgd);
struct amdgpu_fpriv *drv_priv; struct amdgpu_fpriv *drv_priv;
struct amdgpu_vm *avm; struct amdgpu_vm *avm;
int ret; int ret;
...@@ -1359,12 +1352,12 @@ void amdgpu_amdkfd_gpuvm_destroy_cb(struct amdgpu_device *adev, ...@@ -1359,12 +1352,12 @@ void amdgpu_amdkfd_gpuvm_destroy_cb(struct amdgpu_device *adev,
} }
} }
void amdgpu_amdkfd_gpuvm_release_process_vm(struct kgd_dev *kgd, void *drm_priv) void amdgpu_amdkfd_gpuvm_release_process_vm(struct amdgpu_device *adev,
void *drm_priv)
{ {
struct amdgpu_device *adev = get_amdgpu_device(kgd);
struct amdgpu_vm *avm; struct amdgpu_vm *avm;
if (WARN_ON(!kgd || !drm_priv)) if (WARN_ON(!adev || !drm_priv))
return; return;
avm = drm_priv_to_vm(drm_priv); avm = drm_priv_to_vm(drm_priv);
...@@ -1392,11 +1385,10 @@ uint64_t amdgpu_amdkfd_gpuvm_get_process_page_dir(void *drm_priv) ...@@ -1392,11 +1385,10 @@ uint64_t amdgpu_amdkfd_gpuvm_get_process_page_dir(void *drm_priv)
} }
int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
struct kgd_dev *kgd, uint64_t va, uint64_t size, struct amdgpu_device *adev, uint64_t va, uint64_t size,
void *drm_priv, struct kgd_mem **mem, void *drm_priv, struct kgd_mem **mem,
uint64_t *offset, uint32_t flags) uint64_t *offset, uint32_t flags)
{ {
struct amdgpu_device *adev = get_amdgpu_device(kgd);
struct amdgpu_vm *avm = drm_priv_to_vm(drm_priv); struct amdgpu_vm *avm = drm_priv_to_vm(drm_priv);
enum ttm_bo_type bo_type = ttm_bo_type_device; enum ttm_bo_type bo_type = ttm_bo_type_device;
struct sg_table *sg = NULL; struct sg_table *sg = NULL;
...@@ -1529,7 +1521,7 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( ...@@ -1529,7 +1521,7 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
} }
int amdgpu_amdkfd_gpuvm_free_memory_of_gpu( int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
struct kgd_dev *kgd, struct kgd_mem *mem, void *drm_priv, struct amdgpu_device *adev, struct kgd_mem *mem, void *drm_priv,
uint64_t *size) uint64_t *size)
{ {
struct amdkfd_process_info *process_info = mem->process_info; struct amdkfd_process_info *process_info = mem->process_info;
...@@ -1621,10 +1613,9 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu( ...@@ -1621,10 +1613,9 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
} }
int amdgpu_amdkfd_gpuvm_map_memory_to_gpu( int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(
struct kgd_dev *kgd, struct kgd_mem *mem, struct amdgpu_device *adev, struct kgd_mem *mem,
void *drm_priv, bool *table_freed) void *drm_priv, bool *table_freed)
{ {
struct amdgpu_device *adev = get_amdgpu_device(kgd);
struct amdgpu_vm *avm = drm_priv_to_vm(drm_priv); struct amdgpu_vm *avm = drm_priv_to_vm(drm_priv);
int ret; int ret;
struct amdgpu_bo *bo; struct amdgpu_bo *bo;
...@@ -1751,7 +1742,7 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu( ...@@ -1751,7 +1742,7 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(
} }
int amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu( int amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(
struct kgd_dev *kgd, struct kgd_mem *mem, void *drm_priv) struct amdgpu_device *adev, struct kgd_mem *mem, void *drm_priv)
{ {
struct amdgpu_vm *avm = drm_priv_to_vm(drm_priv); struct amdgpu_vm *avm = drm_priv_to_vm(drm_priv);
struct amdkfd_process_info *process_info = avm->process_info; struct amdkfd_process_info *process_info = avm->process_info;
...@@ -1812,7 +1803,7 @@ int amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu( ...@@ -1812,7 +1803,7 @@ int amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(
} }
int amdgpu_amdkfd_gpuvm_sync_memory( int amdgpu_amdkfd_gpuvm_sync_memory(
struct kgd_dev *kgd, struct kgd_mem *mem, bool intr) struct amdgpu_device *adev, struct kgd_mem *mem, bool intr)
{ {
struct amdgpu_sync sync; struct amdgpu_sync sync;
int ret; int ret;
...@@ -1828,7 +1819,7 @@ int amdgpu_amdkfd_gpuvm_sync_memory( ...@@ -1828,7 +1819,7 @@ int amdgpu_amdkfd_gpuvm_sync_memory(
return ret; return ret;
} }
int amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel(struct kgd_dev *kgd, int amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel(struct amdgpu_device *adev,
struct kgd_mem *mem, void **kptr, uint64_t *size) struct kgd_mem *mem, void **kptr, uint64_t *size)
{ {
int ret; int ret;
...@@ -1884,7 +1875,8 @@ int amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel(struct kgd_dev *kgd, ...@@ -1884,7 +1875,8 @@ int amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel(struct kgd_dev *kgd,
return ret; return ret;
} }
void amdgpu_amdkfd_gpuvm_unmap_gtt_bo_from_kernel(struct kgd_dev *kgd, struct kgd_mem *mem) void amdgpu_amdkfd_gpuvm_unmap_gtt_bo_from_kernel(struct amdgpu_device *adev,
struct kgd_mem *mem)
{ {
struct amdgpu_bo *bo = mem->bo; struct amdgpu_bo *bo = mem->bo;
...@@ -1894,12 +1886,9 @@ void amdgpu_amdkfd_gpuvm_unmap_gtt_bo_from_kernel(struct kgd_dev *kgd, struct kg ...@@ -1894,12 +1886,9 @@ void amdgpu_amdkfd_gpuvm_unmap_gtt_bo_from_kernel(struct kgd_dev *kgd, struct kg
amdgpu_bo_unreserve(bo); amdgpu_bo_unreserve(bo);
} }
int amdgpu_amdkfd_gpuvm_get_vm_fault_info(struct kgd_dev *kgd, int amdgpu_amdkfd_gpuvm_get_vm_fault_info(struct amdgpu_device *adev,
struct kfd_vm_fault_info *mem) struct kfd_vm_fault_info *mem)
{ {
struct amdgpu_device *adev;
adev = (struct amdgpu_device *)kgd;
if (atomic_read(&adev->gmc.vm_fault_info_updated) == 1) { if (atomic_read(&adev->gmc.vm_fault_info_updated) == 1) {
*mem = *adev->gmc.vm_fault_info; *mem = *adev->gmc.vm_fault_info;
mb(); mb();
...@@ -1908,13 +1897,12 @@ int amdgpu_amdkfd_gpuvm_get_vm_fault_info(struct kgd_dev *kgd, ...@@ -1908,13 +1897,12 @@ int amdgpu_amdkfd_gpuvm_get_vm_fault_info(struct kgd_dev *kgd,
return 0; return 0;
} }
int amdgpu_amdkfd_gpuvm_import_dmabuf(struct kgd_dev *kgd, int amdgpu_amdkfd_gpuvm_import_dmabuf(struct amdgpu_device *adev,
struct dma_buf *dma_buf, struct dma_buf *dma_buf,
uint64_t va, void *drm_priv, uint64_t va, void *drm_priv,
struct kgd_mem **mem, uint64_t *size, struct kgd_mem **mem, uint64_t *size,
uint64_t *mmap_offset) uint64_t *mmap_offset)
{ {
struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
struct amdgpu_vm *avm = drm_priv_to_vm(drm_priv); struct amdgpu_vm *avm = drm_priv_to_vm(drm_priv);
struct drm_gem_object *obj; struct drm_gem_object *obj;
struct amdgpu_bo *bo; struct amdgpu_bo *bo;
...@@ -2541,11 +2529,9 @@ int amdgpu_amdkfd_remove_gws_from_process(void *info, void *mem) ...@@ -2541,11 +2529,9 @@ int amdgpu_amdkfd_remove_gws_from_process(void *info, void *mem)
} }
/* Returns GPU-specific tiling mode information */ /* Returns GPU-specific tiling mode information */
int amdgpu_amdkfd_get_tile_config(struct kgd_dev *kgd, int amdgpu_amdkfd_get_tile_config(struct amdgpu_device *adev,
struct tile_config *config) struct tile_config *config)
{ {
struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
config->gb_addr_config = adev->gfx.config.gb_addr_config; config->gb_addr_config = adev->gfx.config.gb_addr_config;
config->tile_config_ptr = adev->gfx.config.tile_mode_array; config->tile_config_ptr = adev->gfx.config.tile_mode_array;
config->num_tile_configs = config->num_tile_configs =
......
...@@ -113,7 +113,7 @@ static void cik_event_interrupt_wq(struct kfd_dev *dev, ...@@ -113,7 +113,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));
amdgpu_amdkfd_gpuvm_get_vm_fault_info(dev->kgd, &info); amdgpu_amdkfd_gpuvm_get_vm_fault_info(dev->adev, &info);
if (!info.page_addr && !info.status) if (!info.page_addr && !info.status)
return; return;
......
...@@ -1041,7 +1041,7 @@ static int kfd_ioctl_create_event(struct file *filp, struct kfd_process *p, ...@@ -1041,7 +1041,7 @@ static int kfd_ioctl_create_event(struct file *filp, struct kfd_process *p,
goto out_unlock; goto out_unlock;
} }
err = amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel(kfd->kgd, err = amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel(kfd->adev,
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");
...@@ -1051,7 +1051,7 @@ static int kfd_ioctl_create_event(struct file *filp, struct kfd_process *p, ...@@ -1051,7 +1051,7 @@ static int kfd_ioctl_create_event(struct file *filp, struct kfd_process *p,
err = kfd_event_page_set(p, kern_addr, size); err = kfd_event_page_set(p, kern_addr, size);
if (err) { if (err) {
pr_err("Failed to set event page\n"); pr_err("Failed to set event page\n");
amdgpu_amdkfd_gpuvm_unmap_gtt_bo_from_kernel(kfd->kgd, mem); amdgpu_amdkfd_gpuvm_unmap_gtt_bo_from_kernel(kfd->adev, mem);
goto out_unlock; goto out_unlock;
} }
...@@ -1158,7 +1158,7 @@ static int kfd_ioctl_get_tile_config(struct file *filep, ...@@ -1158,7 +1158,7 @@ static int kfd_ioctl_get_tile_config(struct file *filep,
if (!dev) if (!dev)
return -EINVAL; return -EINVAL;
amdgpu_amdkfd_get_tile_config(dev->kgd, &config); amdgpu_amdkfd_get_tile_config(dev->adev, &config);
args->gb_addr_config = config.gb_addr_config; args->gb_addr_config = config.gb_addr_config;
args->num_banks = config.num_banks; args->num_banks = config.num_banks;
...@@ -1321,7 +1321,7 @@ static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep, ...@@ -1321,7 +1321,7 @@ static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep,
} }
err = amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( err = amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
dev->kgd, args->va_addr, args->size, dev->adev, args->va_addr, args->size,
pdd->drm_priv, (struct kgd_mem **) &mem, &offset, pdd->drm_priv, (struct kgd_mem **) &mem, &offset,
flags); flags);
...@@ -1353,7 +1353,7 @@ static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep, ...@@ -1353,7 +1353,7 @@ static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep,
return 0; return 0;
err_free: err_free:
amdgpu_amdkfd_gpuvm_free_memory_of_gpu(dev->kgd, (struct kgd_mem *)mem, amdgpu_amdkfd_gpuvm_free_memory_of_gpu(dev->adev, (struct kgd_mem *)mem,
pdd->drm_priv, NULL); pdd->drm_priv, NULL);
err_unlock: err_unlock:
mutex_unlock(&p->mutex); mutex_unlock(&p->mutex);
...@@ -1399,7 +1399,7 @@ static int kfd_ioctl_free_memory_of_gpu(struct file *filep, ...@@ -1399,7 +1399,7 @@ static int kfd_ioctl_free_memory_of_gpu(struct file *filep,
goto err_unlock; goto err_unlock;
} }
ret = amdgpu_amdkfd_gpuvm_free_memory_of_gpu(dev->kgd, ret = amdgpu_amdkfd_gpuvm_free_memory_of_gpu(dev->adev,
(struct kgd_mem *)mem, pdd->drm_priv, &size); (struct kgd_mem *)mem, pdd->drm_priv, &size);
/* If freeing the buffer failed, leave the handle in place for /* If freeing the buffer failed, leave the handle in place for
...@@ -1484,7 +1484,7 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep, ...@@ -1484,7 +1484,7 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep,
goto get_mem_obj_from_handle_failed; goto get_mem_obj_from_handle_failed;
} }
err = amdgpu_amdkfd_gpuvm_map_memory_to_gpu( err = amdgpu_amdkfd_gpuvm_map_memory_to_gpu(
peer->kgd, (struct kgd_mem *)mem, peer->adev, (struct kgd_mem *)mem,
peer_pdd->drm_priv, &table_freed); peer_pdd->drm_priv, &table_freed);
if (err) { if (err) {
pr_err("Failed to map to gpu %d/%d\n", pr_err("Failed to map to gpu %d/%d\n",
...@@ -1496,7 +1496,7 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep, ...@@ -1496,7 +1496,7 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep,
mutex_unlock(&p->mutex); mutex_unlock(&p->mutex);
err = amdgpu_amdkfd_gpuvm_sync_memory(dev->kgd, (struct kgd_mem *) mem, true); err = amdgpu_amdkfd_gpuvm_sync_memory(dev->adev, (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;
...@@ -1593,7 +1593,7 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep, ...@@ -1593,7 +1593,7 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep,
goto get_mem_obj_from_handle_failed; goto get_mem_obj_from_handle_failed;
} }
err = amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu( err = amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(
peer->kgd, (struct kgd_mem *)mem, peer_pdd->drm_priv); peer->adev, (struct kgd_mem *)mem, peer_pdd->drm_priv);
if (err) { if (err) {
pr_err("Failed to unmap from gpu %d/%d\n", pr_err("Failed to unmap from gpu %d/%d\n",
i, args->n_devices); i, args->n_devices);
...@@ -1604,7 +1604,7 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep, ...@@ -1604,7 +1604,7 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep,
mutex_unlock(&p->mutex); mutex_unlock(&p->mutex);
if (dev->device_info->asic_family == CHIP_ALDEBARAN) { if (dev->device_info->asic_family == CHIP_ALDEBARAN) {
err = amdgpu_amdkfd_gpuvm_sync_memory(dev->kgd, err = amdgpu_amdkfd_gpuvm_sync_memory(dev->adev,
(struct kgd_mem *) mem, true); (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");
...@@ -1758,7 +1758,7 @@ static int kfd_ioctl_import_dmabuf(struct file *filep, ...@@ -1758,7 +1758,7 @@ static int kfd_ioctl_import_dmabuf(struct file *filep,
goto err_unlock; goto err_unlock;
} }
r = amdgpu_amdkfd_gpuvm_import_dmabuf(dev->kgd, dmabuf, r = amdgpu_amdkfd_gpuvm_import_dmabuf(dev->adev, dmabuf,
args->va_addr, pdd->drm_priv, args->va_addr, pdd->drm_priv,
(struct kgd_mem **)&mem, &size, (struct kgd_mem **)&mem, &size,
NULL); NULL);
...@@ -1779,7 +1779,7 @@ static int kfd_ioctl_import_dmabuf(struct file *filep, ...@@ -1779,7 +1779,7 @@ static int kfd_ioctl_import_dmabuf(struct file *filep,
return 0; return 0;
err_free: err_free:
amdgpu_amdkfd_gpuvm_free_memory_of_gpu(dev->kgd, (struct kgd_mem *)mem, amdgpu_amdkfd_gpuvm_free_memory_of_gpu(dev->adev, (struct kgd_mem *)mem,
pdd->drm_priv, NULL); pdd->drm_priv, NULL);
err_unlock: err_unlock:
mutex_unlock(&p->mutex); mutex_unlock(&p->mutex);
......
...@@ -692,12 +692,12 @@ static void kfd_process_free_gpuvm(struct kgd_mem *mem, ...@@ -692,12 +692,12 @@ static void kfd_process_free_gpuvm(struct kgd_mem *mem,
struct kfd_dev *dev = pdd->dev; struct kfd_dev *dev = pdd->dev;
if (kptr) { if (kptr) {
amdgpu_amdkfd_gpuvm_unmap_gtt_bo_from_kernel(dev->kgd, mem); amdgpu_amdkfd_gpuvm_unmap_gtt_bo_from_kernel(dev->adev, mem);
kptr = NULL; kptr = NULL;
} }
amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(dev->kgd, mem, pdd->drm_priv); amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(dev->adev, mem, pdd->drm_priv);
amdgpu_amdkfd_gpuvm_free_memory_of_gpu(dev->kgd, mem, pdd->drm_priv, amdgpu_amdkfd_gpuvm_free_memory_of_gpu(dev->adev, mem, pdd->drm_priv,
NULL); NULL);
} }
...@@ -714,24 +714,24 @@ static int kfd_process_alloc_gpuvm(struct kfd_process_device *pdd, ...@@ -714,24 +714,24 @@ static int kfd_process_alloc_gpuvm(struct kfd_process_device *pdd,
struct kfd_dev *kdev = pdd->dev; struct kfd_dev *kdev = pdd->dev;
int err; int err;
err = amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(kdev->kgd, gpu_va, size, err = amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(kdev->adev, gpu_va, size,
pdd->drm_priv, mem, NULL, flags); pdd->drm_priv, mem, NULL, flags);
if (err) if (err)
goto err_alloc_mem; goto err_alloc_mem;
err = amdgpu_amdkfd_gpuvm_map_memory_to_gpu(kdev->kgd, *mem, err = amdgpu_amdkfd_gpuvm_map_memory_to_gpu(kdev->adev, *mem,
pdd->drm_priv, NULL); pdd->drm_priv, NULL);
if (err) if (err)
goto err_map_mem; goto err_map_mem;
err = amdgpu_amdkfd_gpuvm_sync_memory(kdev->kgd, *mem, true); err = amdgpu_amdkfd_gpuvm_sync_memory(kdev->adev, *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;
} }
if (kptr) { if (kptr) {
err = amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel(kdev->kgd, err = amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel(kdev->adev,
(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");
...@@ -742,10 +742,10 @@ static int kfd_process_alloc_gpuvm(struct kfd_process_device *pdd, ...@@ -742,10 +742,10 @@ static int kfd_process_alloc_gpuvm(struct kfd_process_device *pdd,
return err; return err;
sync_memory_failed: sync_memory_failed:
amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(kdev->kgd, *mem, pdd->drm_priv); amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(kdev->adev, *mem, pdd->drm_priv);
err_map_mem: err_map_mem:
amdgpu_amdkfd_gpuvm_free_memory_of_gpu(kdev->kgd, *mem, pdd->drm_priv, amdgpu_amdkfd_gpuvm_free_memory_of_gpu(kdev->adev, *mem, pdd->drm_priv,
NULL); NULL);
err_alloc_mem: err_alloc_mem:
*mem = NULL; *mem = NULL;
...@@ -940,10 +940,10 @@ static void kfd_process_device_free_bos(struct kfd_process_device *pdd) ...@@ -940,10 +940,10 @@ static void kfd_process_device_free_bos(struct kfd_process_device *pdd)
if (!peer_pdd->drm_priv) if (!peer_pdd->drm_priv)
continue; continue;
amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu( amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(
peer_pdd->dev->kgd, mem, peer_pdd->drm_priv); peer_pdd->dev->adev, mem, peer_pdd->drm_priv);
} }
amdgpu_amdkfd_gpuvm_free_memory_of_gpu(pdd->dev->kgd, mem, amdgpu_amdkfd_gpuvm_free_memory_of_gpu(pdd->dev->adev, mem,
pdd->drm_priv, NULL); pdd->drm_priv, NULL);
kfd_process_device_remove_obj_handle(pdd, id); kfd_process_device_remove_obj_handle(pdd, id);
} }
...@@ -974,7 +974,7 @@ static void kfd_process_kunmap_signal_bo(struct kfd_process *p) ...@@ -974,7 +974,7 @@ static void kfd_process_kunmap_signal_bo(struct kfd_process *p)
if (!mem) if (!mem)
goto out; goto out;
amdgpu_amdkfd_gpuvm_unmap_gtt_bo_from_kernel(kdev->kgd, mem); amdgpu_amdkfd_gpuvm_unmap_gtt_bo_from_kernel(kdev->adev, mem);
out: out:
mutex_unlock(&p->mutex); mutex_unlock(&p->mutex);
...@@ -1003,7 +1003,7 @@ static void kfd_process_destroy_pdds(struct kfd_process *p) ...@@ -1003,7 +1003,7 @@ static void kfd_process_destroy_pdds(struct kfd_process *p)
if (pdd->drm_file) { if (pdd->drm_file) {
amdgpu_amdkfd_gpuvm_release_process_vm( amdgpu_amdkfd_gpuvm_release_process_vm(
pdd->dev->kgd, pdd->drm_priv); pdd->dev->adev, pdd->drm_priv);
fput(pdd->drm_file); fput(pdd->drm_file);
} }
...@@ -1547,7 +1547,7 @@ int kfd_process_device_init_vm(struct kfd_process_device *pdd, ...@@ -1547,7 +1547,7 @@ int kfd_process_device_init_vm(struct kfd_process_device *pdd,
dev = pdd->dev; dev = pdd->dev;
ret = amdgpu_amdkfd_gpuvm_acquire_process_vm( ret = amdgpu_amdkfd_gpuvm_acquire_process_vm(
dev->kgd, drm_file, p->pasid, dev->adev, drm_file, p->pasid,
&p->kgd_process_info, &p->ef); &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");
......
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