<div dir="ltr"><div class="gmail_default" style="font-size:small">ok, taken to -next.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 31, 2017 at 4:56 PM, Christian König <span dir="ltr"><<a href="mailto:ckoenig.leichtzumerken@gmail.com" target="_blank">ckoenig.leichtzumerken@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Am 31.10.2017 um 11:44 schrieb Oded Gabbay:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Don't have any strong objection, but I just want to ask if current<br>
users can just move to using amdgpu on KV and their current usermode<br>
stack will work as usual.<br>
</blockquote>
<br></span>
Yes, I think so.<span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
btw, are there any "current users" that you are aware of ?<br>
</blockquote>
<br></span>
Not the slightest idea, but from Felix comments at least the current user mode stack + old kernel won't work.<br>
<br>
Regards,<br>
Christian.<div class="HOEnZb"><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
On Mon, Oct 30, 2017 at 3:16 PM, Christian König<br>
<<a href="mailto:deathsimple@vodafone.de" target="_blank">deathsimple@vodafone.de</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
From: Christian König <<a href="mailto:christian.koenig@amd.com" target="_blank">christian.koenig@amd.com</a>><br>
<br>
To quote Felix: "For testing KV with current user mode stack, please use<br>
amdgpu. I don't expect this to work with radeon and I'm not planning to spend<br>
any effort on making radeon work with a current user mode stack."<br>
<br>
Only compile tested, but should be straight forward.<br>
<br>
Signed-off-by: Christian König <<a href="mailto:christian.koenig@amd.com" target="_blank">christian.koenig@amd.com</a>><br>
---<br>
drivers/gpu/drm/amd/amdkfd/Kco<wbr>nfig | 2 +-<br>
drivers/gpu/drm/radeon/Makefil<wbr>e | 3 +-<br>
drivers/gpu/drm/radeon/cik.c | 14 +-<br>
drivers/gpu/drm/radeon/cikd.h | 2 -<br>
drivers/gpu/drm/radeon/radeon.<wbr>h | 3 -<br>
drivers/gpu/drm/radeon/radeon_<wbr>drv.c | 10 -<br>
drivers/gpu/drm/radeon/radeon_<wbr>kfd.c | 901 ------------------------------<wbr>------<br>
drivers/gpu/drm/radeon/radeon_<wbr>kfd.h | 47 --<br>
drivers/gpu/drm/radeon/radeon_<wbr>kms.c | 7 -<br>
9 files changed, 4 insertions(+), 985 deletions(-)<br>
delete mode 100644 drivers/gpu/drm/radeon/radeon_<wbr>kfd.c<br>
delete mode 100644 drivers/gpu/drm/radeon/radeon_<wbr>kfd.h<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdkfd/K<wbr>config b/drivers/gpu/drm/amd/amdkfd/K<wbr>config<br>
index e13c67c..bc5a294 100644<br>
--- a/drivers/gpu/drm/amd/amdkfd/K<wbr>config<br>
+++ b/drivers/gpu/drm/amd/amdkfd/K<wbr>config<br>
@@ -4,6 +4,6 @@<br>
<br>
config HSA_AMD<br>
tristate "HSA kernel driver for AMD GPU devices"<br>
- depends on (DRM_RADEON || DRM_AMDGPU) && AMD_IOMMU_V2 && X86_64<br>
+ depends on DRM_AMDGPU && AMD_IOMMU_V2 && X86_64<br>
help<br>
Enable this if you want to use HSA features on AMD GPU devices.<br>
diff --git a/drivers/gpu/drm/radeon/Makef<wbr>ile b/drivers/gpu/drm/radeon/Makef<wbr>ile<br>
index be16c63..cf3e598 100644<br>
--- a/drivers/gpu/drm/radeon/Makef<wbr>ile<br>
+++ b/drivers/gpu/drm/radeon/Makef<wbr>ile<br>
@@ -102,8 +102,7 @@ radeon-y += \<br>
radeon-y += \<br>
radeon_vce.o \<br>
vce_v1_0.o \<br>
- vce_v2_0.o \<br>
- radeon_kfd.o<br>
+ vce_v2_0.o<br>
<br>
radeon-$(CONFIG_VGA_SWITCHEROO<wbr>) += radeon_atpx_handler.o<br>
radeon-$(CONFIG_ACPI) += radeon_acpi.o<br>
diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c<br>
index 3cb6c55..898f9a0 100644<br>
--- a/drivers/gpu/drm/radeon/cik.c<br>
+++ b/drivers/gpu/drm/radeon/cik.c<br>
@@ -33,7 +33,6 @@<br>
#include "cik_blit_shaders.h"<br>
#include "radeon_ucode.h"<br>
#include "clearstate_ci.h"<br>
-#include "radeon_kfd.h"<br>
<br>
#define SH_MEM_CONFIG_GFX_DEFAULT \<br>
ALIGNMENT_MODE(SH_MEM_ALIGNME<wbr>NT_MODE_UNALIGNED)<br>
@@ -5684,10 +5683,9 @@ int cik_vm_init(struct radeon_device *rdev)<br>
/*<br>
* number of VMs<br>
* VMID 0 is reserved for System<br>
- * radeon graphics/compute will use VMIDs 1-7<br>
- * amdkfd will use VMIDs 8-15<br>
+ * radeon graphics/compute will use VMIDs 1-15<br>
*/<br>
- rdev->vm_manager.nvm = RADEON_NUM_OF_VMIDS;<br>
+ rdev->vm_manager.nvm = 16;<br>
/* base offset of vram pages */<br>
if (rdev->flags & RADEON_IS_IGP) {<br>
u64 tmp = RREG32(MC_VM_FB_OFFSET);<br>
@@ -7589,9 +7587,6 @@ int cik_irq_process(struct radeon_device *rdev)<br>
/* wptr/rptr are in bytes! */<br>
ring_index = rptr / 4;<br>
<br>
- radeon_kfd_interrupt(rdev,<br>
- (const void *) &rdev->ih.ring[ring_index]);<br>
-<br>
src_id = le32_to_cpu(rdev->ih.ring[ring<wbr>_index]) & 0xff;<br>
src_data = le32_to_cpu(rdev->ih.ring[ring<wbr>_index + 1]) & 0xfffffff;<br>
ring_id = le32_to_cpu(rdev->ih.ring[ring<wbr>_index + 2]) & 0xff;<br>
@@ -8486,10 +8481,6 @@ static int cik_startup(struct radeon_device *rdev)<br>
if (r)<br>
return r;<br>
<br>
- r = radeon_kfd_resume(rdev);<br>
- if (r)<br>
- return r;<br>
-<br>
return 0;<br>
}<br>
<br>
@@ -8538,7 +8529,6 @@ int cik_resume(struct radeon_device *rdev)<br>
*/<br>
int cik_suspend(struct radeon_device *rdev)<br>
{<br>
- radeon_kfd_suspend(rdev);<br>
radeon_pm_suspend(rdev);<br>
radeon_audio_fini(rdev);<br>
radeon_vm_manager_fini(rdev);<br>
diff --git a/drivers/gpu/drm/radeon/cikd.<wbr>h b/drivers/gpu/drm/radeon/cikd.<wbr>h<br>
index e210154..cda16fc 100644<br>
--- a/drivers/gpu/drm/radeon/cikd.<wbr>h<br>
+++ b/drivers/gpu/drm/radeon/cikd.<wbr>h<br>
@@ -30,8 +30,6 @@<br>
#define CIK_RB_BITMAP_WIDTH_PER_SH 2<br>
#define HAWAII_RB_BITMAP_WIDTH_PER_SH 4<br>
<br>
-#define RADEON_NUM_OF_VMIDS 8<br>
-<br>
/* DIDT IND registers */<br>
#define DIDT_SQ_CTRL0 0x0<br>
# define DIDT_CTRL_EN (1 << 0)<br>
diff --git a/drivers/gpu/drm/radeon/radeo<wbr>n.h b/drivers/gpu/drm/radeon/radeo<wbr>n.h<br>
index ec63bc5..d94741b 100644<br>
--- a/drivers/gpu/drm/radeon/radeo<wbr>n.h<br>
+++ b/drivers/gpu/drm/radeon/radeo<wbr>n.h<br>
@@ -2456,9 +2456,6 @@ struct radeon_device {<br>
u64 vram_pin_size;<br>
u64 gart_pin_size;<br>
<br>
- /* amdkfd interface */<br>
- struct kfd_dev *kfd;<br>
-<br>
struct mutex mn_lock;<br>
DECLARE_HASHTABLE(mn_hash, 7);<br>
};<br>
diff --git a/drivers/gpu/drm/radeon/radeo<wbr>n_drv.c b/drivers/gpu/drm/radeon/radeo<wbr>n_drv.c<br>
index f4becad..31dd04f 100644<br>
--- a/drivers/gpu/drm/radeon/radeo<wbr>n_drv.c<br>
+++ b/drivers/gpu/drm/radeon/radeo<wbr>n_drv.c<br>
@@ -43,7 +43,6 @@<br>
#include <drm/drm_fb_helper.h><br>
<br>
#include <drm/drm_crtc_helper.h><br>
-#include "radeon_kfd.h"<br>
<br>
/*<br>
* KMS wrapper.<br>
@@ -338,14 +337,6 @@ static int radeon_pci_probe(struct pci_dev *pdev,<br>
{<br>
int ret;<br>
<br>
- /*<br>
- * Initialize amdkfd before starting radeon. If it was not loaded yet,<br>
- * defer radeon probing<br>
- */<br>
- ret = radeon_kfd_init();<br>
- if (ret == -EPROBE_DEFER)<br>
- return ret;<br>
-<br>
if (vga_switcheroo_client_probe_d<wbr>efer(pdev))<br>
return -EPROBE_DEFER;<br>
<br>
@@ -645,7 +636,6 @@ static int __init radeon_init(void)<br>
<br>
static void __exit radeon_exit(void)<br>
{<br>
- radeon_kfd_fini();<br>
pci_unregister_driver(<wbr>pdriver);<br>
radeon_unregister_atpx_handle<wbr>r();<br>
}<br>
diff --git a/drivers/gpu/drm/radeon/radeo<wbr>n_kfd.c b/drivers/gpu/drm/radeon/radeo<wbr>n_kfd.c<br>
deleted file mode 100644<br>
index 385b4d7..0000000<br>
--- a/drivers/gpu/drm/radeon/radeo<wbr>n_kfd.c<br>
+++ /dev/null<br>
@@ -1,901 +0,0 @@<br>
-/*<br>
- * Copyright 2014 Advanced Micro Devices, Inc.<br>
- *<br>
- * Permission is hereby granted, free of charge, to any person obtaining a<br>
- * copy of this software and associated documentation files (the "Software"),<br>
- * to deal in the Software without restriction, including without limitation<br>
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
- * and/or sell copies of the Software, and to permit persons to whom the<br>
- * Software is furnished to do so, subject to the following conditions:<br>
- *<br>
- * The above copyright notice and this permission notice shall be included in<br>
- * all copies or substantial portions of the Software.<br>
- *<br>
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
- * OTHER DEALINGS IN THE SOFTWARE.<br>
- */<br>
-<br>
-#include <linux/module.h><br>
-#include <linux/fdtable.h><br>
-#include <linux/uaccess.h><br>
-#include <drm/drmP.h><br>
-#include "radeon.h"<br>
-#include "cikd.h"<br>
-#include "cik_reg.h"<br>
-#include "radeon_kfd.h"<br>
-#include "radeon_ucode.h"<br>
-#include <linux/firmware.h><br>
-#include "cik_structs.h"<br>
-<br>
-#define CIK_PIPE_PER_MEC (4)<br>
-<br>
-static const uint32_t watchRegs[MAX_WATCH_ADDRESSES * ADDRESS_WATCH_REG_MAX] = {<br>
- TCP_WATCH0_ADDR_H, TCP_WATCH0_ADDR_L, TCP_WATCH0_CNTL,<br>
- TCP_WATCH1_ADDR_H, TCP_WATCH1_ADDR_L, TCP_WATCH1_CNTL,<br>
- TCP_WATCH2_ADDR_H, TCP_WATCH2_ADDR_L, TCP_WATCH2_CNTL,<br>
- TCP_WATCH3_ADDR_H, TCP_WATCH3_ADDR_L, TCP_WATCH3_CNTL<br>
-};<br>
-<br>
-struct kgd_mem {<br>
- struct radeon_bo *bo;<br>
- uint64_t gpu_addr;<br>
- void *cpu_ptr;<br>
-};<br>
-<br>
-<br>
-static int alloc_gtt_mem(struct kgd_dev *kgd, size_t size,<br>
- void **mem_obj, uint64_t *gpu_addr,<br>
- void **cpu_ptr);<br>
-<br>
-static void free_gtt_mem(struct kgd_dev *kgd, void *mem_obj);<br>
-<br>
-static uint64_t get_vmem_size(struct kgd_dev *kgd);<br>
-static uint64_t get_gpu_clock_counter(struct kgd_dev *kgd);<br>
-<br>
-static uint32_t get_max_engine_clock_in_mhz(st<wbr>ruct kgd_dev *kgd);<br>
-<br>
-static int alloc_pasid(unsigned int bits);<br>
-static void free_pasid(unsigned int pasid);<br>
-<br>
-static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type);<br>
-<br>
-/*<br>
- * Register access functions<br>
- */<br>
-<br>
-static void kgd_program_sh_mem_settings(st<wbr>ruct kgd_dev *kgd, uint32_t vmid,<br>
- uint32_t sh_mem_config, uint32_t sh_mem_ape1_base,<br>
- uint32_t sh_mem_ape1_limit, uint32_t sh_mem_bases);<br>
-<br>
-static int kgd_set_pasid_vmid_mapping(str<wbr>uct kgd_dev *kgd, unsigned int pasid,<br>
- unsigned int vmid);<br>
-<br>
-static int kgd_init_pipeline(struct kgd_dev *kgd, uint32_t pipe_id,<br>
- uint32_t hpd_size, uint64_t hpd_gpu_addr);<br>
-static int kgd_init_interrupts(struct kgd_dev *kgd, uint32_t pipe_id);<br>
-static int kgd_hqd_load(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id,<br>
- uint32_t queue_id, uint32_t __user *wptr,<br>
- uint32_t wptr_shift, uint32_t wptr_mask,<br>
- struct mm_struct *mm);<br>
-static int kgd_hqd_sdma_load(struct kgd_dev *kgd, void *mqd);<br>
-static bool kgd_hqd_is_occupied(struct kgd_dev *kgd, uint64_t queue_address,<br>
- uint32_t pipe_id, uint32_t queue_id);<br>
-<br>
-static int kgd_hqd_destroy(struct kgd_dev *kgd, void *mqd, uint32_t reset_type,<br>
- unsigned int timeout, uint32_t pipe_id,<br>
- uint32_t queue_id);<br>
-static bool kgd_hqd_sdma_is_occupied(struc<wbr>t kgd_dev *kgd, void *mqd);<br>
-static int kgd_hqd_sdma_destroy(struct kgd_dev *kgd, void *mqd,<br>
- unsigned int timeout);<br>
-static int kgd_address_watch_disable(stru<wbr>ct kgd_dev *kgd);<br>
-static int kgd_address_watch_execute(stru<wbr>ct kgd_dev *kgd,<br>
- unsigned int watch_point_id,<br>
- uint32_t cntl_val,<br>
- uint32_t addr_hi,<br>
- uint32_t addr_lo);<br>
-static int kgd_wave_control_execute(struc<wbr>t kgd_dev *kgd,<br>
- uint32_t gfx_index_val,<br>
- uint32_t sq_cmd);<br>
-static uint32_t kgd_address_watch_get_offset(s<wbr>truct kgd_dev *kgd,<br>
- unsigned int watch_point_id,<br>
- unsigned int reg_offset);<br>
-<br>
-static bool get_atc_vmid_pasid_mapping_val<wbr>id(struct kgd_dev *kgd, uint8_t vmid);<br>
-static uint16_t get_atc_vmid_pasid_mapping_pas<wbr>id(struct kgd_dev *kgd,<br>
- uint8_t vmid);<br>
-static void write_vmid_invalidate_request(<wbr>struct kgd_dev *kgd, uint8_t vmid);<br>
-<br>
-static const struct kfd2kgd_calls kfd2kgd = {<br>
- .init_gtt_mem_allocation = alloc_gtt_mem,<br>
- .free_gtt_mem = free_gtt_mem,<br>
- .get_vmem_size = get_vmem_size,<br>
- .get_gpu_clock_counter = get_gpu_clock_counter,<br>
- .get_max_engine_clock_in_mhz = get_max_engine_clock_in_mhz,<br>
- .alloc_pasid = alloc_pasid,<br>
- .free_pasid = free_pasid,<br>
- .program_sh_mem_settings = kgd_program_sh_mem_settings,<br>
- .set_pasid_vmid_mapping = kgd_set_pasid_vmid_mapping,<br>
- .init_pipeline = kgd_init_pipeline,<br>
- .init_interrupts = kgd_init_interrupts,<br>
- .hqd_load = kgd_hqd_load,<br>
- .hqd_sdma_load = kgd_hqd_sdma_load,<br>
- .hqd_is_occupied = kgd_hqd_is_occupied,<br>
- .hqd_sdma_is_occupied = kgd_hqd_sdma_is_occupied,<br>
- .hqd_destroy = kgd_hqd_destroy,<br>
- .hqd_sdma_destroy = kgd_hqd_sdma_destroy,<br>
- .address_watch_disable = kgd_address_watch_disable,<br>
- .address_watch_execute = kgd_address_watch_execute,<br>
- .wave_control_execute = kgd_wave_control_execute,<br>
- .address_watch_get_offset = kgd_address_watch_get_offset,<br>
- .get_atc_vmid_pasid_mapping_p<wbr>asid = get_atc_vmid_pasid_mapping_pas<wbr>id,<br>
- .get_atc_vmid_pasid_mapping_v<wbr>alid = get_atc_vmid_pasid_mapping_val<wbr>id,<br>
- .write_vmid_invalidate_<wbr>request = write_vmid_invalidate_request,<br>
- .get_fw_version = get_fw_version<br>
-};<br>
-<br>
-static const struct kgd2kfd_calls *kgd2kfd;<br>
-<br>
-int radeon_kfd_init(void)<br>
-{<br>
- int ret;<br>
-<br>
-#if defined(CONFIG_HSA_AMD_MODULE)<br>
- int (*kgd2kfd_init_p)(unsigned, const struct kgd2kfd_calls**);<br>
-<br>
- kgd2kfd_init_p = symbol_request(kgd2kfd_init);<br>
-<br>
- if (kgd2kfd_init_p == NULL)<br>
- return -ENOENT;<br>
-<br>
- ret = kgd2kfd_init_p(KFD_INTERFACE_V<wbr>ERSION, &kgd2kfd);<br>
- if (ret) {<br>
- symbol_put(kgd2kfd_init);<br>
- kgd2kfd = NULL;<br>
- }<br>
-<br>
-#elif defined(CONFIG_HSA_AMD)<br>
- ret = kgd2kfd_init(KFD_INTERFACE_VER<wbr>SION, &kgd2kfd);<br>
- if (ret)<br>
- kgd2kfd = NULL;<br>
-<br>
-#else<br>
- ret = -ENOENT;<br>
-#endif<br>
-<br>
- return ret;<br>
-}<br>
-<br>
-void radeon_kfd_fini(void)<br>
-{<br>
- if (kgd2kfd) {<br>
- kgd2kfd->exit();<br>
- symbol_put(kgd2kfd_init);<br>
- }<br>
-}<br>
-<br>
-void radeon_kfd_device_probe(struct radeon_device *rdev)<br>
-{<br>
- if (kgd2kfd)<br>
- rdev->kfd = kgd2kfd->probe((struct kgd_dev *)rdev,<br>
- rdev->pdev, &kfd2kgd);<br>
-}<br>
-<br>
-void radeon_kfd_device_init(struct radeon_device *rdev)<br>
-{<br>
- int i, queue, pipe, mec;<br>
-<br>
- if (rdev->kfd) {<br>
- struct kgd2kfd_shared_resources gpu_resources = {<br>
- .compute_vmid_bitmap = 0xFF00,<br>
- .num_pipe_per_mec = 4,<br>
- .num_queue_per_pipe = 8<br>
- };<br>
-<br>
- bitmap_zero(gpu_resources.que<wbr>ue_bitmap, KGD_MAX_QUEUES);<br>
-<br>
- for (i = 0; i < KGD_MAX_QUEUES; ++i) {<br>
- queue = i % gpu_resources.num_queue_per_pi<wbr>pe;<br>
- pipe = (i / gpu_resources.num_queue_per_pi<wbr>pe)<br>
- % gpu_resources.num_pipe_per_mec<wbr>;<br>
- mec = (i / gpu_resources.num_queue_per_pi<wbr>pe)<br>
- / gpu_resources.num_pipe_per_mec<wbr>;<br>
-<br>
- if (mec == 0 && pipe > 0)<br>
- set_bit(i, gpu_resources.queue_bitmap);<br>
- }<br>
-<br>
- radeon_doorbell_get_kfd_info(<wbr>rdev,<br>
- &gpu_resources.doorbell_physi<wbr>cal_address,<br>
- &gpu_resources.doorbell_apert<wbr>ure_size,<br>
- &gpu_resources.doorbell_<wbr>start_offset);<br>
-<br>
- kgd2kfd->device_init(rdev->kf<wbr>d, &gpu_resources);<br>
- }<br>
-}<br>
-<br>
-void radeon_kfd_device_fini(struct radeon_device *rdev)<br>
-{<br>
- if (rdev->kfd) {<br>
- kgd2kfd->device_exit(rdev->kf<wbr>d);<br>
- rdev->kfd = NULL;<br>
- }<br>
-}<br>
-<br>
-void radeon_kfd_interrupt(struct radeon_device *rdev, const void *ih_ring_entry)<br>
-{<br>
- if (rdev->kfd)<br>
- kgd2kfd->interrupt(rdev->kfd, ih_ring_entry);<br>
-}<br>
-<br>
-void radeon_kfd_suspend(struct radeon_device *rdev)<br>
-{<br>
- if (rdev->kfd)<br>
- kgd2kfd->suspend(rdev->kfd);<br>
-}<br>
-<br>
-int radeon_kfd_resume(struct radeon_device *rdev)<br>
-{<br>
- int r = 0;<br>
-<br>
- if (rdev->kfd)<br>
- r = kgd2kfd->resume(rdev->kfd);<br>
-<br>
- return r;<br>
-}<br>
-<br>
-static int alloc_gtt_mem(struct kgd_dev *kgd, size_t size,<br>
- void **mem_obj, uint64_t *gpu_addr,<br>
- void **cpu_ptr)<br>
-{<br>
- struct radeon_device *rdev = (struct radeon_device *)kgd;<br>
- struct kgd_mem **mem = (struct kgd_mem **) mem_obj;<br>
- int r;<br>
-<br>
- BUG_ON(kgd == NULL);<br>
- BUG_ON(gpu_addr == NULL);<br>
- BUG_ON(cpu_ptr == NULL);<br>
-<br>
- *mem = kmalloc(sizeof(struct kgd_mem), GFP_KERNEL);<br>
- if ((*mem) == NULL)<br>
- return -ENOMEM;<br>
-<br>
- r = radeon_bo_create(rdev, size, PAGE_SIZE, true, RADEON_GEM_DOMAIN_GTT,<br>
- RADEON_GEM_GTT_WC, NULL, NULL, &(*mem)->bo);<br>
- if (r) {<br>
- dev_err(rdev->dev,<br>
- "failed to allocate BO for amdkfd (%d)\n", r);<br>
- return r;<br>
- }<br>
-<br>
- /* map the buffer */<br>
- r = radeon_bo_reserve((*mem)->bo, true);<br>
- if (r) {<br>
- dev_err(rdev->dev, "(%d) failed to reserve bo for amdkfd\n", r);<br>
- goto allocate_mem_reserve_bo_failed<wbr>;<br>
- }<br>
-<br>
- r = radeon_bo_pin((*mem)->bo, RADEON_GEM_DOMAIN_GTT,<br>
- &(*mem)->gpu_addr);<br>
- if (r) {<br>
- dev_err(rdev->dev, "(%d) failed to pin bo for amdkfd\n", r);<br>
- goto allocate_mem_pin_bo_failed;<br>
- }<br>
- *gpu_addr = (*mem)->gpu_addr;<br>
-<br>
- r = radeon_bo_kmap((*mem)->bo, &(*mem)->cpu_ptr);<br>
- if (r) {<br>
- dev_err(rdev->dev,<br>
- "(%d) failed to map bo to kernel for amdkfd\n", r);<br>
- goto allocate_mem_kmap_bo_failed;<br>
- }<br>
- *cpu_ptr = (*mem)->cpu_ptr;<br>
-<br>
- radeon_bo_unreserve((*mem)->b<wbr>o);<br>
-<br>
- return 0;<br>
-<br>
-allocate_mem_kmap_bo_failed:<br>
- radeon_bo_unpin((*mem)->bo);<br>
-allocate_mem_pin_bo_failed:<br>
- radeon_bo_unreserve((*mem)->b<wbr>o);<br>
-allocate_mem_reserve_bo_faile<wbr>d:<br>
- radeon_bo_unref(&(*mem)->bo);<br>
-<br>
- return r;<br>
-}<br>
-<br>
-static void free_gtt_mem(struct kgd_dev *kgd, void *mem_obj)<br>
-{<br>
- struct kgd_mem *mem = (struct kgd_mem *) mem_obj;<br>
-<br>
- BUG_ON(mem == NULL);<br>
-<br>
- radeon_bo_reserve(mem->bo, true);<br>
- radeon_bo_kunmap(mem->bo);<br>
- radeon_bo_unpin(mem->bo);<br>
- radeon_bo_unreserve(mem->bo);<br>
- radeon_bo_unref(&(mem->bo));<br>
- kfree(mem);<br>
-}<br>
-<br>
-static uint64_t get_vmem_size(struct kgd_dev *kgd)<br>
-{<br>
- struct radeon_device *rdev = (struct radeon_device *)kgd;<br>
-<br>
- BUG_ON(kgd == NULL);<br>
-<br>
- return rdev->mc.real_vram_size;<br>
-}<br>
-<br>
-static uint64_t get_gpu_clock_counter(struct kgd_dev *kgd)<br>
-{<br>
- struct radeon_device *rdev = (struct radeon_device *)kgd;<br>
-<br>
- return rdev->asic->get_gpu_clock_coun<wbr>ter(rdev);<br>
-}<br>
-<br>
-static uint32_t get_max_engine_clock_in_mhz(st<wbr>ruct kgd_dev *kgd)<br>
-{<br>
- struct radeon_device *rdev = (struct radeon_device *)kgd;<br>
-<br>
- /* The sclk is in quantas of 10kHz */<br>
- return rdev->pm.dpm.dyn_state.max_clo<wbr>ck_voltage_on_ac.sclk / 100;<br>
-}<br>
-<br>
-/*<br>
- * PASID manager<br>
- */<br>
-static DEFINE_IDA(pasid_ida);<br>
-<br>
-static int alloc_pasid(unsigned int bits)<br>
-{<br>
- int pasid = -EINVAL;<br>
-<br>
- for (bits = min(bits, 31U); bits > 0; bits--) {<br>
- pasid = ida_simple_get(&pasid_ida,<br>
- 1U << (bits - 1), 1U << bits,<br>
- GFP_KERNEL);<br>
- if (pasid != -ENOSPC)<br>
- break;<br>
- }<br>
-<br>
- return pasid;<br>
-}<br>
-<br>
-static void free_pasid(unsigned int pasid)<br>
-{<br>
- ida_simple_remove(&pasid_ida, pasid);<br>
-}<br>
-<br>
-static inline struct radeon_device *get_radeon_device(struct kgd_dev *kgd)<br>
-{<br>
- return (struct radeon_device *)kgd;<br>
-}<br>
-<br>
-static void write_register(struct kgd_dev *kgd, uint32_t offset, uint32_t value)<br>
-{<br>
- struct radeon_device *rdev = get_radeon_device(kgd);<br>
-<br>
- writel(value, (void __iomem *)(rdev->rmmio + offset));<br>
-}<br>
-<br>
-static uint32_t read_register(struct kgd_dev *kgd, uint32_t offset)<br>
-{<br>
- struct radeon_device *rdev = get_radeon_device(kgd);<br>
-<br>
- return readl((void __iomem *)(rdev->rmmio + offset));<br>
-}<br>
-<br>
-static void lock_srbm(struct kgd_dev *kgd, uint32_t mec, uint32_t pipe,<br>
- uint32_t queue, uint32_t vmid)<br>
-{<br>
- struct radeon_device *rdev = get_radeon_device(kgd);<br>
- uint32_t value = PIPEID(pipe) | MEID(mec) | VMID(vmid) | QUEUEID(queue);<br>
-<br>
- mutex_lock(&rdev->srbm_mutex)<wbr>;<br>
- write_register(kgd, SRBM_GFX_CNTL, value);<br>
-}<br>
-<br>
-static void unlock_srbm(struct kgd_dev *kgd)<br>
-{<br>
- struct radeon_device *rdev = get_radeon_device(kgd);<br>
-<br>
- write_register(kgd, SRBM_GFX_CNTL, 0);<br>
- mutex_unlock(&rdev->srbm_mute<wbr>x);<br>
-}<br>
-<br>
-static void acquire_queue(struct kgd_dev *kgd, uint32_t pipe_id,<br>
- uint32_t queue_id)<br>
-{<br>
- uint32_t mec = (++pipe_id / CIK_PIPE_PER_MEC) + 1;<br>
- uint32_t pipe = (pipe_id % CIK_PIPE_PER_MEC);<br>
-<br>
- lock_srbm(kgd, mec, pipe, queue_id, 0);<br>
-}<br>
-<br>
-static void release_queue(struct kgd_dev *kgd)<br>
-{<br>
- unlock_srbm(kgd);<br>
-}<br>
-<br>
-static void kgd_program_sh_mem_settings(st<wbr>ruct kgd_dev *kgd, uint32_t vmid,<br>
- uint32_t sh_mem_config,<br>
- uint32_t sh_mem_ape1_base,<br>
- uint32_t sh_mem_ape1_limit,<br>
- uint32_t sh_mem_bases)<br>
-{<br>
- lock_srbm(kgd, 0, 0, 0, vmid);<br>
-<br>
- write_register(kgd, SH_MEM_CONFIG, sh_mem_config);<br>
- write_register(kgd, SH_MEM_APE1_BASE, sh_mem_ape1_base);<br>
- write_register(kgd, SH_MEM_APE1_LIMIT, sh_mem_ape1_limit);<br>
- write_register(kgd, SH_MEM_BASES, sh_mem_bases);<br>
-<br>
- unlock_srbm(kgd);<br>
-}<br>
-<br>
-static int kgd_set_pasid_vmid_mapping(str<wbr>uct kgd_dev *kgd, unsigned int pasid,<br>
- unsigned int vmid)<br>
-{<br>
- /*<br>
- * We have to assume that there is no outstanding mapping.<br>
- * The ATC_VMID_PASID_MAPPING_UPDATE_<wbr>STATUS bit could be 0<br>
- * because a mapping is in progress or because a mapping finished and<br>
- * the SW cleared it.<br>
- * So the protocol is to always wait & clear.<br>
- */<br>
- uint32_t pasid_mapping = (pasid == 0) ? 0 : (uint32_t)pasid |<br>
- ATC_VMID_PASID_MAPPING_VALID_<wbr>MASK;<br>
-<br>
- write_register(kgd, ATC_VMID0_PASID_MAPPING + vmid*sizeof(uint32_t),<br>
- pasid_mapping);<br>
-<br>
- while (!(read_register(kgd, ATC_VMID_PASID_MAPPING_UPDATE_<wbr>STATUS) &<br>
- (1U << vmid)))<br>
- cpu_relax();<br>
- write_register(kgd, ATC_VMID_PASID_MAPPING_UPDATE_<wbr>STATUS, 1U << vmid);<br>
-<br>
- /* Mapping vmid to pasid also for IH block */<br>
- write_register(kgd, IH_VMID_0_LUT + vmid * sizeof(uint32_t),<br>
- pasid_mapping);<br>
-<br>
- return 0;<br>
-}<br>
-<br>
-static int kgd_init_pipeline(struct kgd_dev *kgd, uint32_t pipe_id,<br>
- uint32_t hpd_size, uint64_t hpd_gpu_addr)<br>
-{<br>
- /* nothing to do here */<br>
- return 0;<br>
-}<br>
-<br>
-static int kgd_init_interrupts(struct kgd_dev *kgd, uint32_t pipe_id)<br>
-{<br>
- uint32_t mec;<br>
- uint32_t pipe;<br>
-<br>
- mec = (pipe_id / CIK_PIPE_PER_MEC) + 1;<br>
- pipe = (pipe_id % CIK_PIPE_PER_MEC);<br>
-<br>
- lock_srbm(kgd, mec, pipe, 0, 0);<br>
-<br>
- write_register(kgd, CPC_INT_CNTL,<br>
- TIME_STAMP_INT_ENABLE | OPCODE_ERROR_INT_ENABLE);<br>
-<br>
- unlock_srbm(kgd);<br>
-<br>
- return 0;<br>
-}<br>
-<br>
-static inline uint32_t get_sdma_base_addr(struct cik_sdma_rlc_registers *m)<br>
-{<br>
- uint32_t retval;<br>
-<br>
- retval = m->sdma_engine_id * SDMA1_REGISTER_OFFSET +<br>
- m->sdma_queue_id * KFD_CIK_SDMA_QUEUE_OFFSET;<br>
-<br>
- pr_debug("kfd: sdma base address: 0x%x\n", retval);<br>
-<br>
- return retval;<br>
-}<br>
-<br>
-static inline struct cik_mqd *get_mqd(void *mqd)<br>
-{<br>
- return (struct cik_mqd *)mqd;<br>
-}<br>
-<br>
-static inline struct cik_sdma_rlc_registers *get_sdma_mqd(void *mqd)<br>
-{<br>
- return (struct cik_sdma_rlc_registers *)mqd;<br>
-}<br>
-<br>
-static int kgd_hqd_load(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id,<br>
- uint32_t queue_id, uint32_t __user *wptr,<br>
- uint32_t wptr_shift, uint32_t wptr_mask,<br>
- struct mm_struct *mm)<br>
-{<br>
- uint32_t wptr_shadow, is_wptr_shadow_valid;<br>
- struct cik_mqd *m;<br>
-<br>
- m = get_mqd(mqd);<br>
-<br>
- is_wptr_shadow_valid = !get_user(wptr_shadow, wptr);<br>
-<br>
- acquire_queue(kgd, pipe_id, queue_id);<br>
- write_register(kgd, CP_MQD_BASE_ADDR, m->cp_mqd_base_addr_lo);<br>
- write_register(kgd, CP_MQD_BASE_ADDR_HI, m->cp_mqd_base_addr_hi);<br>
- write_register(kgd, CP_MQD_CONTROL, m->cp_mqd_control);<br>
-<br>
- write_register(kgd, CP_HQD_PQ_BASE, m->cp_hqd_pq_base_lo);<br>
- write_register(kgd, CP_HQD_PQ_BASE_HI, m->cp_hqd_pq_base_hi);<br>
- write_register(kgd, CP_HQD_PQ_CONTROL, m->cp_hqd_pq_control);<br>
-<br>
- write_register(kgd, CP_HQD_IB_CONTROL, m->cp_hqd_ib_control);<br>
- write_register(kgd, CP_HQD_IB_BASE_ADDR, m->cp_hqd_ib_base_addr_lo);<br>
- write_register(kgd, CP_HQD_IB_BASE_ADDR_HI, m->cp_hqd_ib_base_addr_hi);<br>
-<br>
- write_register(kgd, CP_HQD_IB_RPTR, m->cp_hqd_ib_rptr);<br>
-<br>
- write_register(kgd, CP_HQD_PERSISTENT_STATE,<br>
- m->cp_hqd_persistent_state);<br>
- write_register(kgd, CP_HQD_SEMA_CMD, m->cp_hqd_sema_cmd);<br>
- write_register(kgd, CP_HQD_MSG_TYPE, m->cp_hqd_msg_type);<br>
-<br>
- write_register(kgd, CP_HQD_ATOMIC0_PREOP_LO,<br>
- m->cp_hqd_atomic0_preop_lo);<br>
-<br>
- write_register(kgd, CP_HQD_ATOMIC0_PREOP_HI,<br>
- m->cp_hqd_atomic0_preop_hi);<br>
-<br>
- write_register(kgd, CP_HQD_ATOMIC1_PREOP_LO,<br>
- m->cp_hqd_atomic1_preop_lo);<br>
-<br>
- write_register(kgd, CP_HQD_ATOMIC1_PREOP_HI,<br>
- m->cp_hqd_atomic1_preop_hi);<br>
-<br>
- write_register(kgd, CP_HQD_PQ_RPTR_REPORT_ADDR,<br>
- m->cp_hqd_pq_rptr_report_<wbr>addr_lo);<br>
-<br>
- write_register(kgd, CP_HQD_PQ_RPTR_REPORT_ADDR_HI,<br>
- m->cp_hqd_pq_rptr_report_<wbr>addr_hi);<br>
-<br>
- write_register(kgd, CP_HQD_PQ_RPTR, m->cp_hqd_pq_rptr);<br>
-<br>
- write_register(kgd, CP_HQD_PQ_WPTR_POLL_ADDR,<br>
- m->cp_hqd_pq_wptr_poll_addr_l<wbr>o);<br>
-<br>
- write_register(kgd, CP_HQD_PQ_WPTR_POLL_ADDR_HI,<br>
- m->cp_hqd_pq_wptr_poll_addr_h<wbr>i);<br>
-<br>
- write_register(kgd, CP_HQD_PQ_DOORBELL_CONTROL,<br>
- m->cp_hqd_pq_doorbell_<wbr>control);<br>
-<br>
- write_register(kgd, CP_HQD_VMID, m->cp_hqd_vmid);<br>
-<br>
- write_register(kgd, CP_HQD_QUANTUM, m->cp_hqd_quantum);<br>
-<br>
- write_register(kgd, CP_HQD_PIPE_PRIORITY, m->cp_hqd_pipe_priority);<br>
- write_register(kgd, CP_HQD_QUEUE_PRIORITY, m->cp_hqd_queue_priority);<br>
-<br>
- write_register(kgd, CP_HQD_IQ_RPTR, m->cp_hqd_iq_rptr);<br>
-<br>
- if (is_wptr_shadow_valid)<br>
- write_register(kgd, CP_HQD_PQ_WPTR, wptr_shadow);<br>
-<br>
- write_register(kgd, CP_HQD_ACTIVE, m->cp_hqd_active);<br>
- release_queue(kgd);<br>
-<br>
- return 0;<br>
-}<br>
-<br>
-static int kgd_hqd_sdma_load(struct kgd_dev *kgd, void *mqd)<br>
-{<br>
- struct cik_sdma_rlc_registers *m;<br>
- uint32_t sdma_base_addr;<br>
-<br>
- m = get_sdma_mqd(mqd);<br>
- sdma_base_addr = get_sdma_base_addr(m);<br>
-<br>
- write_register(kgd,<br>
- sdma_base_addr + SDMA0_RLC0_VIRTUAL_ADDR,<br>
- m->sdma_rlc_virtual_addr);<br>
-<br>
- write_register(kgd,<br>
- sdma_base_addr + SDMA0_RLC0_RB_BASE,<br>
- m->sdma_rlc_rb_base);<br>
-<br>
- write_register(kgd,<br>
- sdma_base_addr + SDMA0_RLC0_RB_BASE_HI,<br>
- m->sdma_rlc_rb_base_hi);<br>
-<br>
- write_register(kgd,<br>
- sdma_base_addr + SDMA0_RLC0_RB_RPTR_ADDR_LO,<br>
- m->sdma_rlc_rb_rptr_addr_lo);<br>
-<br>
- write_register(kgd,<br>
- sdma_base_addr + SDMA0_RLC0_RB_RPTR_ADDR_HI,<br>
- m->sdma_rlc_rb_rptr_addr_hi);<br>
-<br>
- write_register(kgd,<br>
- sdma_base_addr + SDMA0_RLC0_DOORBELL,<br>
- m->sdma_rlc_doorbell);<br>
-<br>
- write_register(kgd,<br>
- sdma_base_addr + SDMA0_RLC0_RB_CNTL,<br>
- m->sdma_rlc_rb_cntl);<br>
-<br>
- return 0;<br>
-}<br>
-<br>
-static bool kgd_hqd_is_occupied(struct kgd_dev *kgd, uint64_t queue_address,<br>
- uint32_t pipe_id, uint32_t queue_id)<br>
-{<br>
- uint32_t act;<br>
- bool retval = false;<br>
- uint32_t low, high;<br>
-<br>
- acquire_queue(kgd, pipe_id, queue_id);<br>
- act = read_register(kgd, CP_HQD_ACTIVE);<br>
- if (act) {<br>
- low = lower_32_bits(queue_address >> 8);<br>
- high = upper_32_bits(queue_address >> 8);<br>
-<br>
- if (low == read_register(kgd, CP_HQD_PQ_BASE) &&<br>
- high == read_register(kgd, CP_HQD_PQ_BASE_HI))<br>
- retval = true;<br>
- }<br>
- release_queue(kgd);<br>
- return retval;<br>
-}<br>
-<br>
-static bool kgd_hqd_sdma_is_occupied(struc<wbr>t kgd_dev *kgd, void *mqd)<br>
-{<br>
- struct cik_sdma_rlc_registers *m;<br>
- uint32_t sdma_base_addr;<br>
- uint32_t sdma_rlc_rb_cntl;<br>
-<br>
- m = get_sdma_mqd(mqd);<br>
- sdma_base_addr = get_sdma_base_addr(m);<br>
-<br>
- sdma_rlc_rb_cntl = read_register(kgd,<br>
- sdma_base_addr + SDMA0_RLC0_RB_CNTL);<br>
-<br>
- if (sdma_rlc_rb_cntl & SDMA_RB_ENABLE)<br>
- return true;<br>
-<br>
- return false;<br>
-}<br>
-<br>
-static int kgd_hqd_destroy(struct kgd_dev *kgd, void *mqd, uint32_t reset_type,<br>
- unsigned int timeout, uint32_t pipe_id,<br>
- uint32_t queue_id)<br>
-{<br>
- uint32_t temp;<br>
-<br>
- acquire_queue(kgd, pipe_id, queue_id);<br>
- write_register(kgd, CP_HQD_PQ_DOORBELL_CONTROL, 0);<br>
-<br>
- write_register(kgd, CP_HQD_DEQUEUE_REQUEST, reset_type);<br>
-<br>
- while (true) {<br>
- temp = read_register(kgd, CP_HQD_ACTIVE);<br>
- if (temp & 0x1)<br>
- break;<br>
- if (timeout == 0) {<br>
- pr_err("kfd: cp queue preemption time out (%dms)\n",<br>
- temp);<br>
- release_queue(kgd);<br>
- return -ETIME;<br>
- }<br>
- msleep(20);<br>
- timeout -= 20;<br>
- }<br>
-<br>
- release_queue(kgd);<br>
- return 0;<br>
-}<br>
-<br>
-static int kgd_hqd_sdma_destroy(struct kgd_dev *kgd, void *mqd,<br>
- unsigned int timeout)<br>
-{<br>
- struct cik_sdma_rlc_registers *m;<br>
- uint32_t sdma_base_addr;<br>
- uint32_t temp;<br>
-<br>
- m = get_sdma_mqd(mqd);<br>
- sdma_base_addr = get_sdma_base_addr(m);<br>
-<br>
- temp = read_register(kgd, sdma_base_addr + SDMA0_RLC0_RB_CNTL);<br>
- temp = temp & ~SDMA_RB_ENABLE;<br>
- write_register(kgd, sdma_base_addr + SDMA0_RLC0_RB_CNTL, temp);<br>
-<br>
- while (true) {<br>
- temp = read_register(kgd, sdma_base_addr +<br>
- SDMA0_RLC0_CONTEXT_STATUS);<br>
- if (temp & SDMA_RLC_IDLE)<br>
- break;<br>
- if (timeout == 0)<br>
- return -ETIME;<br>
- msleep(20);<br>
- timeout -= 20;<br>
- }<br>
-<br>
- write_register(kgd, sdma_base_addr + SDMA0_RLC0_DOORBELL, 0);<br>
- write_register(kgd, sdma_base_addr + SDMA0_RLC0_RB_RPTR, 0);<br>
- write_register(kgd, sdma_base_addr + SDMA0_RLC0_RB_WPTR, 0);<br>
- write_register(kgd, sdma_base_addr + SDMA0_RLC0_RB_BASE, 0);<br>
-<br>
- return 0;<br>
-}<br>
-<br>
-static int kgd_address_watch_disable(stru<wbr>ct kgd_dev *kgd)<br>
-{<br>
- union TCP_WATCH_CNTL_BITS cntl;<br>
- unsigned int i;<br>
-<br>
- cntl.u32All = 0;<br>
-<br>
- cntl.bitfields.valid = 0;<br>
- cntl.bitfields.mask = ADDRESS_WATCH_REG_CNTL_DEFAULT<wbr>_MASK;<br>
- cntl.bitfields.atc = 1;<br>
-<br>
- /* Turning off this address until we set all the registers */<br>
- for (i = 0; i < MAX_WATCH_ADDRESSES; i++)<br>
- write_register(kgd,<br>
- watchRegs[i * ADDRESS_WATCH_REG_MAX +<br>
- ADDRESS_WATCH_REG_CNTL],<br>
- cntl.u32All);<br>
-<br>
- return 0;<br>
-}<br>
-<br>
-static int kgd_address_watch_execute(stru<wbr>ct kgd_dev *kgd,<br>
- unsigned int watch_point_id,<br>
- uint32_t cntl_val,<br>
- uint32_t addr_hi,<br>
- uint32_t addr_lo)<br>
-{<br>
- union TCP_WATCH_CNTL_BITS cntl;<br>
-<br>
- cntl.u32All = cntl_val;<br>
-<br>
- /* Turning off this watch point until we set all the registers */<br>
- cntl.bitfields.valid = 0;<br>
- write_register(kgd,<br>
- watchRegs[watch_point_id * ADDRESS_WATCH_REG_MAX +<br>
- ADDRESS_WATCH_REG_CNTL],<br>
- cntl.u32All);<br>
-<br>
- write_register(kgd,<br>
- watchRegs[watch_point_id * ADDRESS_WATCH_REG_MAX +<br>
- ADDRESS_WATCH_REG_ADDR_HI],<br>
- addr_hi);<br>
-<br>
- write_register(kgd,<br>
- watchRegs[watch_point_id * ADDRESS_WATCH_REG_MAX +<br>
- ADDRESS_WATCH_REG_ADDR_LO],<br>
- addr_lo);<br>
-<br>
- /* Enable the watch point */<br>
- cntl.bitfields.valid = 1;<br>
-<br>
- write_register(kgd,<br>
- watchRegs[watch_point_id * ADDRESS_WATCH_REG_MAX +<br>
- ADDRESS_WATCH_REG_CNTL],<br>
- cntl.u32All);<br>
-<br>
- return 0;<br>
-}<br>
-<br>
-static int kgd_wave_control_execute(struc<wbr>t kgd_dev *kgd,<br>
- uint32_t gfx_index_val,<br>
- uint32_t sq_cmd)<br>
-{<br>
- struct radeon_device *rdev = get_radeon_device(kgd);<br>
- uint32_t data;<br>
-<br>
- mutex_lock(&rdev->grbm_idx_mu<wbr>tex);<br>
-<br>
- write_register(kgd, GRBM_GFX_INDEX, gfx_index_val);<br>
- write_register(kgd, SQ_CMD, sq_cmd);<br>
-<br>
- /* Restore the GRBM_GFX_INDEX register */<br>
-<br>
- data = INSTANCE_BROADCAST_WRITES | SH_BROADCAST_WRITES |<br>
- SE_BROADCAST_WRITES;<br>
-<br>
- write_register(kgd, GRBM_GFX_INDEX, data);<br>
-<br>
- mutex_unlock(&rdev->grbm_idx_<wbr>mutex);<br>
-<br>
- return 0;<br>
-}<br>
-<br>
-static uint32_t kgd_address_watch_get_offset(s<wbr>truct kgd_dev *kgd,<br>
- unsigned int watch_point_id,<br>
- unsigned int reg_offset)<br>
-{<br>
- return watchRegs[watch_point_id * ADDRESS_WATCH_REG_MAX + reg_offset]<br>
- / 4;<br>
-}<br>
-<br>
-static bool get_atc_vmid_pasid_mapping_val<wbr>id(struct kgd_dev *kgd, uint8_t vmid)<br>
-{<br>
- uint32_t reg;<br>
- struct radeon_device *rdev = (struct radeon_device *) kgd;<br>
-<br>
- reg = RREG32(ATC_VMID0_PASID_MAPPING + vmid*4);<br>
- return reg & ATC_VMID_PASID_MAPPING_VALID_M<wbr>ASK;<br>
-}<br>
-<br>
-static uint16_t get_atc_vmid_pasid_mapping_pas<wbr>id(struct kgd_dev *kgd,<br>
- uint8_t vmid)<br>
-{<br>
- uint32_t reg;<br>
- struct radeon_device *rdev = (struct radeon_device *) kgd;<br>
-<br>
- reg = RREG32(ATC_VMID0_PASID_MAPPING + vmid*4);<br>
- return reg & ATC_VMID_PASID_MAPPING_PASID_M<wbr>ASK;<br>
-}<br>
-<br>
-static void write_vmid_invalidate_request(<wbr>struct kgd_dev *kgd, uint8_t vmid)<br>
-{<br>
- struct radeon_device *rdev = (struct radeon_device *) kgd;<br>
-<br>
- return WREG32(VM_INVALIDATE_REQUEST, 1 << vmid);<br>
-}<br>
-<br>
-static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type)<br>
-{<br>
- struct radeon_device *rdev = (struct radeon_device *) kgd;<br>
- const union radeon_firmware_header *hdr;<br>
-<br>
- BUG_ON(kgd == NULL || rdev->mec_fw == NULL);<br>
-<br>
- switch (type) {<br>
- case KGD_ENGINE_PFP:<br>
- hdr = (const union radeon_firmware_header *) rdev->pfp_fw->data;<br>
- break;<br>
-<br>
- case KGD_ENGINE_ME:<br>
- hdr = (const union radeon_firmware_header *) rdev->me_fw->data;<br>
- break;<br>
-<br>
- case KGD_ENGINE_CE:<br>
- hdr = (const union radeon_firmware_header *) rdev->ce_fw->data;<br>
- break;<br>
-<br>
- case KGD_ENGINE_MEC1:<br>
- hdr = (const union radeon_firmware_header *) rdev->mec_fw->data;<br>
- break;<br>
-<br>
- case KGD_ENGINE_MEC2:<br>
- hdr = (const union radeon_firmware_header *)<br>
- rdev->mec2_fw->data;<br>
- break;<br>
-<br>
- case KGD_ENGINE_RLC:<br>
- hdr = (const union radeon_firmware_header *) rdev->rlc_fw->data;<br>
- break;<br>
-<br>
- case KGD_ENGINE_SDMA1:<br>
- case KGD_ENGINE_SDMA2:<br>
- hdr = (const union radeon_firmware_header *)<br>
- rdev->sdma_fw->data;<br>
- break;<br>
-<br>
- default:<br>
- return 0;<br>
- }<br>
-<br>
- if (hdr == NULL)<br>
- return 0;<br>
-<br>
- /* Only 12 bit in use*/<br>
- return hdr->common.ucode_version;<br>
-}<br>
diff --git a/drivers/gpu/drm/radeon/radeo<wbr>n_kfd.h b/drivers/gpu/drm/radeon/radeo<wbr>n_kfd.h<br>
deleted file mode 100644<br>
index 9df1fea..0000000<br>
--- a/drivers/gpu/drm/radeon/radeo<wbr>n_kfd.h<br>
+++ /dev/null<br>
@@ -1,47 +0,0 @@<br>
-/*<br>
- * Copyright 2014 Advanced Micro Devices, Inc.<br>
- *<br>
- * Permission is hereby granted, free of charge, to any person obtaining a<br>
- * copy of this software and associated documentation files (the "Software"),<br>
- * to deal in the Software without restriction, including without limitation<br>
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
- * and/or sell copies of the Software, and to permit persons to whom the<br>
- * Software is furnished to do so, subject to the following conditions:<br>
- *<br>
- * The above copyright notice and this permission notice shall be included in<br>
- * all copies or substantial portions of the Software.<br>
- *<br>
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
- * OTHER DEALINGS IN THE SOFTWARE.<br>
- */<br>
-<br>
-/*<br>
- * radeon_kfd.h defines the private interface between the<br>
- * AMD kernel graphics drivers and the AMD KFD.<br>
- */<br>
-<br>
-#ifndef RADEON_KFD_H_INCLUDED<br>
-#define RADEON_KFD_H_INCLUDED<br>
-<br>
-#include <linux/types.h><br>
-#include "kgd_kfd_interface.h"<br>
-<br>
-struct radeon_device;<br>
-<br>
-int radeon_kfd_init(void);<br>
-void radeon_kfd_fini(void);<br>
-<br>
-void radeon_kfd_suspend(struct radeon_device *rdev);<br>
-int radeon_kfd_resume(struct radeon_device *rdev);<br>
-void radeon_kfd_interrupt(struct radeon_device *rdev,<br>
- const void *ih_ring_entry);<br>
-void radeon_kfd_device_probe(struct radeon_device *rdev);<br>
-void radeon_kfd_device_init(struct radeon_device *rdev);<br>
-void radeon_kfd_device_fini(struct radeon_device *rdev);<br>
-<br>
-#endif /* RADEON_KFD_H_INCLUDED */<br>
diff --git a/drivers/gpu/drm/radeon/radeo<wbr>n_kms.c b/drivers/gpu/drm/radeon/radeo<wbr>n_kms.c<br>
index dfee8f7..cde037f 100644<br>
--- a/drivers/gpu/drm/radeon/radeo<wbr>n_kms.c<br>
+++ b/drivers/gpu/drm/radeon/radeo<wbr>n_kms.c<br>
@@ -34,8 +34,6 @@<br>
#include <linux/slab.h><br>
#include <linux/pm_runtime.h><br>
<br>
-#include "radeon_kfd.h"<br>
-<br>
#if defined(CONFIG_VGA_SWITCHEROO)<br>
bool radeon_has_atpx(void);<br>
#else<br>
@@ -68,8 +66,6 @@ void radeon_driver_unload_kms(struc<wbr>t drm_device *dev)<br>
pm_runtime_forbid(dev->dev);<br>
}<br>
<br>
- radeon_kfd_device_fini(rdev);<br>
-<br>
radeon_acpi_fini(rdev);<br>
<br>
radeon_modeset_fini(rdev);<br>
@@ -174,9 +170,6 @@ int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags)<br>
"Error during ACPI methods call\n");<br>
}<br>
<br>
- radeon_kfd_device_probe(rdev)<wbr>;<br>
- radeon_kfd_device_init(rdev);<br>
-<br>
if (radeon_is_px(dev)) {<br>
pm_runtime_use_autosuspend(de<wbr>v->dev);<br>
pm_runtime_set_autosuspend_de<wbr>lay(dev->dev, 5000);<br>
--<br>
2.7.4<br>
<br>
______________________________<wbr>_________________<br>
amd-gfx mailing list<br>
<a href="mailto:amd-gfx@lists.freedesktop.org" target="_blank">amd-gfx@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/amd-gfx</a><br>
</blockquote>
______________________________<wbr>_________________<br>
amd-gfx mailing list<br>
<a href="mailto:amd-gfx@lists.freedesktop.org" target="_blank">amd-gfx@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/amd-gfx</a><br>
</blockquote>
<br>
<br>
</div></div></blockquote></div><br></div>