Commit 8e07e267 authored by Amber Lin's avatar Amber Lin Committed by Alex Deucher

drm/amdgpu: Simplify kgd2kfd interface

After amdkfd is merged into amdgpu module, amdgpu can call amdkfd
functions directly.
Signed-off-by: default avatarAmber Lin <Amber.Lin@amd.com>
Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Acked-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 2d3d25b6
...@@ -61,17 +61,13 @@ int amdgpu_amdkfd_init(void) ...@@ -61,17 +61,13 @@ int amdgpu_amdkfd_init(void)
void amdgpu_amdkfd_fini(void) void amdgpu_amdkfd_fini(void)
{ {
if (kgd2kfd) kgd2kfd_exit();
kgd2kfd->exit();
} }
void amdgpu_amdkfd_device_probe(struct amdgpu_device *adev) void amdgpu_amdkfd_device_probe(struct amdgpu_device *adev)
{ {
const struct kfd2kgd_calls *kfd2kgd; const struct kfd2kgd_calls *kfd2kgd;
if (!kgd2kfd)
return;
switch (adev->asic_type) { switch (adev->asic_type) {
#ifdef CONFIG_DRM_AMDGPU_CIK #ifdef CONFIG_DRM_AMDGPU_CIK
case CHIP_KAVERI: case CHIP_KAVERI:
...@@ -98,8 +94,8 @@ void amdgpu_amdkfd_device_probe(struct amdgpu_device *adev) ...@@ -98,8 +94,8 @@ void amdgpu_amdkfd_device_probe(struct amdgpu_device *adev)
return; return;
} }
adev->kfd.dev = kgd2kfd->probe((struct kgd_dev *)adev, adev->kfd.dev = kgd2kfd_probe((struct kgd_dev *)adev,
adev->pdev, kfd2kgd); adev->pdev, kfd2kgd);
if (adev->kfd.dev) if (adev->kfd.dev)
amdgpu_amdkfd_total_mem_size += adev->gmc.real_vram_size; amdgpu_amdkfd_total_mem_size += adev->gmc.real_vram_size;
...@@ -182,7 +178,7 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev) ...@@ -182,7 +178,7 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev)
&gpu_resources.doorbell_start_offset); &gpu_resources.doorbell_start_offset);
if (adev->asic_type < CHIP_VEGA10) { if (adev->asic_type < CHIP_VEGA10) {
kgd2kfd->device_init(adev->kfd.dev, &gpu_resources); kgd2kfd_device_init(adev->kfd.dev, &gpu_resources);
return; return;
} }
...@@ -211,14 +207,14 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev) ...@@ -211,14 +207,14 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev)
gpu_resources.reserved_doorbell_mask = 0x1e0; gpu_resources.reserved_doorbell_mask = 0x1e0;
gpu_resources.reserved_doorbell_val = 0x0e0; gpu_resources.reserved_doorbell_val = 0x0e0;
kgd2kfd->device_init(adev->kfd.dev, &gpu_resources); kgd2kfd_device_init(adev->kfd.dev, &gpu_resources);
} }
} }
void amdgpu_amdkfd_device_fini(struct amdgpu_device *adev) void amdgpu_amdkfd_device_fini(struct amdgpu_device *adev)
{ {
if (adev->kfd.dev) { if (adev->kfd.dev) {
kgd2kfd->device_exit(adev->kfd.dev); kgd2kfd_device_exit(adev->kfd.dev);
adev->kfd.dev = NULL; adev->kfd.dev = NULL;
} }
} }
...@@ -227,13 +223,13 @@ void amdgpu_amdkfd_interrupt(struct amdgpu_device *adev, ...@@ -227,13 +223,13 @@ void amdgpu_amdkfd_interrupt(struct amdgpu_device *adev,
const void *ih_ring_entry) const void *ih_ring_entry)
{ {
if (adev->kfd.dev) if (adev->kfd.dev)
kgd2kfd->interrupt(adev->kfd.dev, ih_ring_entry); kgd2kfd_interrupt(adev->kfd.dev, ih_ring_entry);
} }
void amdgpu_amdkfd_suspend(struct amdgpu_device *adev) void amdgpu_amdkfd_suspend(struct amdgpu_device *adev)
{ {
if (adev->kfd.dev) if (adev->kfd.dev)
kgd2kfd->suspend(adev->kfd.dev); kgd2kfd_suspend(adev->kfd.dev);
} }
int amdgpu_amdkfd_resume(struct amdgpu_device *adev) int amdgpu_amdkfd_resume(struct amdgpu_device *adev)
...@@ -241,7 +237,7 @@ int amdgpu_amdkfd_resume(struct amdgpu_device *adev) ...@@ -241,7 +237,7 @@ int amdgpu_amdkfd_resume(struct amdgpu_device *adev)
int r = 0; int r = 0;
if (adev->kfd.dev) if (adev->kfd.dev)
r = kgd2kfd->resume(adev->kfd.dev); r = kgd2kfd_resume(adev->kfd.dev);
return r; return r;
} }
...@@ -251,7 +247,7 @@ int amdgpu_amdkfd_pre_reset(struct amdgpu_device *adev) ...@@ -251,7 +247,7 @@ int amdgpu_amdkfd_pre_reset(struct amdgpu_device *adev)
int r = 0; int r = 0;
if (adev->kfd.dev) if (adev->kfd.dev)
r = kgd2kfd->pre_reset(adev->kfd.dev); r = kgd2kfd_pre_reset(adev->kfd.dev);
return r; return r;
} }
...@@ -261,7 +257,7 @@ int amdgpu_amdkfd_post_reset(struct amdgpu_device *adev) ...@@ -261,7 +257,7 @@ int amdgpu_amdkfd_post_reset(struct amdgpu_device *adev)
int r = 0; int r = 0;
if (adev->kfd.dev) if (adev->kfd.dev)
r = kgd2kfd->post_reset(adev->kfd.dev); r = kgd2kfd_post_reset(adev->kfd.dev);
return r; return r;
} }
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
static const struct dma_fence_ops amdkfd_fence_ops; static const struct dma_fence_ops amdkfd_fence_ops;
static atomic_t fence_seq = ATOMIC_INIT(0); static atomic_t fence_seq = ATOMIC_INIT(0);
extern const struct kgd2kfd_calls *kgd2kfd;
/* Eviction Fence /* Eviction Fence
* Fence helper functions to deal with KFD memory eviction. * Fence helper functions to deal with KFD memory eviction.
...@@ -123,7 +122,7 @@ static bool amdkfd_fence_enable_signaling(struct dma_fence *f) ...@@ -123,7 +122,7 @@ static bool amdkfd_fence_enable_signaling(struct dma_fence *f)
if (dma_fence_is_signaled(f)) if (dma_fence_is_signaled(f))
return true; return true;
if (!kgd2kfd->schedule_evict_and_restore_process(fence->mm, f)) if (!kgd2kfd_schedule_evict_and_restore_process(fence->mm, f))
return true; return true;
return false; return false;
......
...@@ -44,8 +44,6 @@ ...@@ -44,8 +44,6 @@
*/ */
#define AMDGPU_USERPTR_RESTORE_DELAY_MS 1 #define AMDGPU_USERPTR_RESTORE_DELAY_MS 1
extern const struct kgd2kfd_calls *kgd2kfd;
/* Impose limit on how much memory KFD can use */ /* Impose limit on how much memory KFD can use */
static struct { static struct {
uint64_t max_system_mem_limit; uint64_t max_system_mem_limit;
...@@ -1792,7 +1790,7 @@ int amdgpu_amdkfd_evict_userptr(struct kgd_mem *mem, ...@@ -1792,7 +1790,7 @@ int amdgpu_amdkfd_evict_userptr(struct kgd_mem *mem,
evicted_bos = atomic_inc_return(&process_info->evicted_bos); evicted_bos = atomic_inc_return(&process_info->evicted_bos);
if (evicted_bos == 1) { if (evicted_bos == 1) {
/* First eviction, stop the queues */ /* First eviction, stop the queues */
r = kgd2kfd->quiesce_mm(mm); r = kgd2kfd_quiesce_mm(mm);
if (r) if (r)
pr_err("Failed to quiesce KFD\n"); pr_err("Failed to quiesce KFD\n");
schedule_delayed_work(&process_info->restore_userptr_work, schedule_delayed_work(&process_info->restore_userptr_work,
...@@ -2084,7 +2082,7 @@ static void amdgpu_amdkfd_restore_userptr_worker(struct work_struct *work) ...@@ -2084,7 +2082,7 @@ static void amdgpu_amdkfd_restore_userptr_worker(struct work_struct *work)
evicted_bos) evicted_bos)
goto unlock_out; goto unlock_out;
evicted_bos = 0; evicted_bos = 0;
if (kgd2kfd->resume_mm(mm)) { if (kgd2kfd_resume_mm(mm)) {
pr_err("%s: Failed to resume KFD\n", __func__); pr_err("%s: Failed to resume KFD\n", __func__);
/* No recovery from this failure. Probably the CP is /* No recovery from this failure. Probably the CP is
* hanging. No point trying again. * hanging. No point trying again.
......
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