2 * Copyright 2014 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
23 #include "amdgpu_amdkfd.h"
25 #include "amd_shared.h"
28 #include "amdgpu_gfx.h"
29 #include "amdgpu_dma_buf.h"
30 #include <linux/module.h>
31 #include <linux/dma-buf.h>
32 #include "amdgpu_xgmi.h"
33 #include <uapi/linux/kfd_ioctl.h>
35 /* Total memory size in system memory and all GPU VRAM. Used to
36 * estimate worst case amount of memory to reserve for page tables
38 uint64_t amdgpu_amdkfd_total_mem_size;
40 static bool kfd_initialized;
42 int amdgpu_amdkfd_init(void)
48 amdgpu_amdkfd_total_mem_size = si.freeram - si.freehigh;
49 amdgpu_amdkfd_total_mem_size *= si.mem_unit;
52 amdgpu_amdkfd_gpuvm_init_mem_limits();
53 kfd_initialized = !ret;
58 void amdgpu_amdkfd_fini(void)
60 if (kfd_initialized) {
62 kfd_initialized = false;
66 void amdgpu_amdkfd_device_probe(struct amdgpu_device *adev)
68 bool vf = amdgpu_sriov_vf(adev);
73 adev->kfd.dev = kgd2kfd_probe((struct kgd_dev *)adev,
74 adev->pdev, adev->asic_type, vf);
77 amdgpu_amdkfd_total_mem_size += adev->gmc.real_vram_size;
81 * amdgpu_doorbell_get_kfd_info - Report doorbell configuration required to
84 * @adev: amdgpu_device pointer
85 * @aperture_base: output returning doorbell aperture base physical address
86 * @aperture_size: output returning doorbell aperture size in bytes
87 * @start_offset: output returning # of doorbell bytes reserved for amdgpu.
89 * amdgpu and amdkfd share the doorbell aperture. amdgpu sets it up,
90 * takes doorbells required for its own rings and reports the setup to amdkfd.
91 * amdgpu reserved doorbells are at the start of the doorbell aperture.
93 static void amdgpu_doorbell_get_kfd_info(struct amdgpu_device *adev,
94 phys_addr_t *aperture_base,
95 size_t *aperture_size,
99 * The first num_doorbells are used by amdgpu.
100 * amdkfd takes whatever's left in the aperture.
102 if (adev->doorbell.size > adev->doorbell.num_doorbells * sizeof(u32)) {
103 *aperture_base = adev->doorbell.base;
104 *aperture_size = adev->doorbell.size;
105 *start_offset = adev->doorbell.num_doorbells * sizeof(u32);
113 void amdgpu_amdkfd_device_init(struct amdgpu_device *adev)
119 struct kgd2kfd_shared_resources gpu_resources = {
120 .compute_vmid_bitmap =
121 ((1 << AMDGPU_NUM_VMID) - 1) -
122 ((1 << adev->vm_manager.first_kfd_vmid) - 1),
123 .num_pipe_per_mec = adev->gfx.mec.num_pipe_per_mec,
124 .num_queue_per_pipe = adev->gfx.mec.num_queue_per_pipe,
125 .gpuvm_size = min(adev->vm_manager.max_pfn
126 << AMDGPU_GPU_PAGE_SHIFT,
127 AMDGPU_GMC_HOLE_START),
128 .drm_render_minor = adev_to_drm(adev)->render->index,
129 .sdma_doorbell_idx = adev->doorbell_index.sdma_engine,
133 /* this is going to have a few of the MSBs set that we need to
136 bitmap_complement(gpu_resources.cp_queue_bitmap,
137 adev->gfx.mec.queue_bitmap,
140 /* According to linux/bitmap.h we shouldn't use bitmap_clear if
141 * nbits is not compile time constant
143 last_valid_bit = 1 /* only first MEC can have compute queues */
144 * adev->gfx.mec.num_pipe_per_mec
145 * adev->gfx.mec.num_queue_per_pipe;
146 for (i = last_valid_bit; i < KGD_MAX_QUEUES; ++i)
147 clear_bit(i, gpu_resources.cp_queue_bitmap);
149 amdgpu_doorbell_get_kfd_info(adev,
150 &gpu_resources.doorbell_physical_address,
151 &gpu_resources.doorbell_aperture_size,
152 &gpu_resources.doorbell_start_offset);
154 /* Since SOC15, BIF starts to statically use the
155 * lower 12 bits of doorbell addresses for routing
156 * based on settings in registers like
157 * SDMA0_DOORBELL_RANGE etc..
158 * In order to route a doorbell to CP engine, the lower
159 * 12 bits of its address has to be outside the range
160 * set for SDMA, VCN, and IH blocks.
162 if (adev->asic_type >= CHIP_VEGA10) {
163 gpu_resources.non_cp_doorbells_start =
164 adev->doorbell_index.first_non_cp;
165 gpu_resources.non_cp_doorbells_end =
166 adev->doorbell_index.last_non_cp;
169 adev->kfd.init_complete = kgd2kfd_device_init(adev->kfd.dev,
170 adev_to_drm(adev), &gpu_resources);
174 void amdgpu_amdkfd_device_fini_sw(struct amdgpu_device *adev)
177 kgd2kfd_device_exit(adev->kfd.dev);
178 adev->kfd.dev = NULL;
182 void amdgpu_amdkfd_interrupt(struct amdgpu_device *adev,
183 const void *ih_ring_entry)
186 kgd2kfd_interrupt(adev->kfd.dev, ih_ring_entry);
189 void amdgpu_amdkfd_suspend(struct amdgpu_device *adev, bool run_pm)
192 kgd2kfd_suspend(adev->kfd.dev, run_pm);
195 int amdgpu_amdkfd_resume(struct amdgpu_device *adev, bool run_pm)
200 r = kgd2kfd_resume(adev->kfd.dev, run_pm);
205 int amdgpu_amdkfd_pre_reset(struct amdgpu_device *adev)
210 r = kgd2kfd_pre_reset(adev->kfd.dev);
215 int amdgpu_amdkfd_post_reset(struct amdgpu_device *adev)
220 r = kgd2kfd_post_reset(adev->kfd.dev);
225 void amdgpu_amdkfd_gpu_reset(struct kgd_dev *kgd)
227 struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
229 if (amdgpu_device_should_recover_gpu(adev))
230 amdgpu_device_gpu_recover(adev, NULL);
233 int amdgpu_amdkfd_alloc_gtt_mem(struct kgd_dev *kgd, size_t size,
234 void **mem_obj, uint64_t *gpu_addr,
235 void **cpu_ptr, bool cp_mqd_gfx9)
237 struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
238 struct amdgpu_bo *bo = NULL;
239 struct amdgpu_bo_param bp;
241 void *cpu_ptr_tmp = NULL;
243 memset(&bp, 0, sizeof(bp));
245 bp.byte_align = PAGE_SIZE;
246 bp.domain = AMDGPU_GEM_DOMAIN_GTT;
247 bp.flags = AMDGPU_GEM_CREATE_CPU_GTT_USWC;
248 bp.type = ttm_bo_type_kernel;
250 bp.bo_ptr_size = sizeof(struct amdgpu_bo);
253 bp.flags |= AMDGPU_GEM_CREATE_CP_MQD_GFX9;
255 r = amdgpu_bo_create(adev, &bp, &bo);
258 "failed to allocate BO for amdkfd (%d)\n", r);
263 r = amdgpu_bo_reserve(bo, true);
265 dev_err(adev->dev, "(%d) failed to reserve bo for amdkfd\n", r);
266 goto allocate_mem_reserve_bo_failed;
269 r = amdgpu_bo_pin(bo, AMDGPU_GEM_DOMAIN_GTT);
271 dev_err(adev->dev, "(%d) failed to pin bo for amdkfd\n", r);
272 goto allocate_mem_pin_bo_failed;
275 r = amdgpu_ttm_alloc_gart(&bo->tbo);
277 dev_err(adev->dev, "%p bind failed\n", bo);
278 goto allocate_mem_kmap_bo_failed;
281 r = amdgpu_bo_kmap(bo, &cpu_ptr_tmp);
284 "(%d) failed to map bo to kernel for amdkfd\n", r);
285 goto allocate_mem_kmap_bo_failed;
289 *gpu_addr = amdgpu_bo_gpu_offset(bo);
290 *cpu_ptr = cpu_ptr_tmp;
292 amdgpu_bo_unreserve(bo);
296 allocate_mem_kmap_bo_failed:
298 allocate_mem_pin_bo_failed:
299 amdgpu_bo_unreserve(bo);
300 allocate_mem_reserve_bo_failed:
301 amdgpu_bo_unref(&bo);
306 void amdgpu_amdkfd_free_gtt_mem(struct kgd_dev *kgd, void *mem_obj)
308 struct amdgpu_bo *bo = (struct amdgpu_bo *) mem_obj;
310 amdgpu_bo_reserve(bo, true);
311 amdgpu_bo_kunmap(bo);
313 amdgpu_bo_unreserve(bo);
314 amdgpu_bo_unref(&(bo));
317 int amdgpu_amdkfd_alloc_gws(struct kgd_dev *kgd, size_t size,
320 struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
321 struct amdgpu_bo *bo = NULL;
322 struct amdgpu_bo_user *ubo;
323 struct amdgpu_bo_param bp;
326 memset(&bp, 0, sizeof(bp));
329 bp.domain = AMDGPU_GEM_DOMAIN_GWS;
330 bp.flags = AMDGPU_GEM_CREATE_NO_CPU_ACCESS;
331 bp.type = ttm_bo_type_device;
333 bp.bo_ptr_size = sizeof(struct amdgpu_bo);
335 r = amdgpu_bo_create_user(adev, &bp, &ubo);
338 "failed to allocate gws BO for amdkfd (%d)\n", r);
347 void amdgpu_amdkfd_free_gws(struct kgd_dev *kgd, void *mem_obj)
349 struct amdgpu_bo *bo = (struct amdgpu_bo *)mem_obj;
351 amdgpu_bo_unref(&bo);
354 uint32_t amdgpu_amdkfd_get_fw_version(struct kgd_dev *kgd,
355 enum kgd_engine_type type)
357 struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
361 return adev->gfx.pfp_fw_version;
364 return adev->gfx.me_fw_version;
367 return adev->gfx.ce_fw_version;
369 case KGD_ENGINE_MEC1:
370 return adev->gfx.mec_fw_version;
372 case KGD_ENGINE_MEC2:
373 return adev->gfx.mec2_fw_version;
376 return adev->gfx.rlc_fw_version;
378 case KGD_ENGINE_SDMA1:
379 return adev->sdma.instance[0].fw_version;
381 case KGD_ENGINE_SDMA2:
382 return adev->sdma.instance[1].fw_version;
391 void amdgpu_amdkfd_get_local_mem_info(struct kgd_dev *kgd,
392 struct kfd_local_mem_info *mem_info)
394 struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
396 memset(mem_info, 0, sizeof(*mem_info));
398 mem_info->local_mem_size_public = adev->gmc.visible_vram_size;
399 mem_info->local_mem_size_private = adev->gmc.real_vram_size -
400 adev->gmc.visible_vram_size;
402 mem_info->vram_width = adev->gmc.vram_width;
404 pr_debug("Address base: %pap public 0x%llx private 0x%llx\n",
405 &adev->gmc.aper_base,
406 mem_info->local_mem_size_public,
407 mem_info->local_mem_size_private);
409 if (amdgpu_sriov_vf(adev))
410 mem_info->mem_clk_max = adev->clock.default_mclk / 100;
411 else if (adev->pm.dpm_enabled) {
412 if (amdgpu_emu_mode == 1)
413 mem_info->mem_clk_max = 0;
415 mem_info->mem_clk_max = amdgpu_dpm_get_mclk(adev, false) / 100;
417 mem_info->mem_clk_max = 100;
420 uint64_t amdgpu_amdkfd_get_gpu_clock_counter(struct kgd_dev *kgd)
422 struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
424 if (adev->gfx.funcs->get_gpu_clock_counter)
425 return adev->gfx.funcs->get_gpu_clock_counter(adev);
429 uint32_t amdgpu_amdkfd_get_max_engine_clock_in_mhz(struct kgd_dev *kgd)
431 struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
433 /* the sclk is in quantas of 10kHz */
434 if (amdgpu_sriov_vf(adev))
435 return adev->clock.default_sclk / 100;
436 else if (adev->pm.dpm_enabled)
437 return amdgpu_dpm_get_sclk(adev, false) / 100;
442 void amdgpu_amdkfd_get_cu_info(struct kgd_dev *kgd, struct kfd_cu_info *cu_info)
444 struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
445 struct amdgpu_cu_info acu_info = adev->gfx.cu_info;
447 memset(cu_info, 0, sizeof(*cu_info));
448 if (sizeof(cu_info->cu_bitmap) != sizeof(acu_info.bitmap))
451 cu_info->cu_active_number = acu_info.number;
452 cu_info->cu_ao_mask = acu_info.ao_cu_mask;
453 memcpy(&cu_info->cu_bitmap[0], &acu_info.bitmap[0],
454 sizeof(acu_info.bitmap));
455 cu_info->num_shader_engines = adev->gfx.config.max_shader_engines;
456 cu_info->num_shader_arrays_per_engine = adev->gfx.config.max_sh_per_se;
457 cu_info->num_cu_per_sh = adev->gfx.config.max_cu_per_sh;
458 cu_info->simd_per_cu = acu_info.simd_per_cu;
459 cu_info->max_waves_per_simd = acu_info.max_waves_per_simd;
460 cu_info->wave_front_size = acu_info.wave_front_size;
461 cu_info->max_scratch_slots_per_cu = acu_info.max_scratch_slots_per_cu;
462 cu_info->lds_size = acu_info.lds_size;
465 int amdgpu_amdkfd_get_dmabuf_info(struct kgd_dev *kgd, int dma_buf_fd,
466 struct kgd_dev **dma_buf_kgd,
467 uint64_t *bo_size, void *metadata_buffer,
468 size_t buffer_size, uint32_t *metadata_size,
471 struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
472 struct dma_buf *dma_buf;
473 struct drm_gem_object *obj;
474 struct amdgpu_bo *bo;
475 uint64_t metadata_flags;
478 dma_buf = dma_buf_get(dma_buf_fd);
480 return PTR_ERR(dma_buf);
482 if (dma_buf->ops != &amdgpu_dmabuf_ops)
483 /* Can't handle non-graphics buffers */
487 if (obj->dev->driver != adev_to_drm(adev)->driver)
488 /* Can't handle buffers from different drivers */
491 adev = drm_to_adev(obj->dev);
492 bo = gem_to_amdgpu_bo(obj);
493 if (!(bo->preferred_domains & (AMDGPU_GEM_DOMAIN_VRAM |
494 AMDGPU_GEM_DOMAIN_GTT)))
495 /* Only VRAM and GTT BOs are supported */
500 *dma_buf_kgd = (struct kgd_dev *)adev;
502 *bo_size = amdgpu_bo_size(bo);
504 r = amdgpu_bo_get_metadata(bo, metadata_buffer, buffer_size,
505 metadata_size, &metadata_flags);
507 *flags = (bo->preferred_domains & AMDGPU_GEM_DOMAIN_VRAM) ?
508 KFD_IOC_ALLOC_MEM_FLAGS_VRAM
509 : KFD_IOC_ALLOC_MEM_FLAGS_GTT;
511 if (bo->flags & AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED)
512 *flags |= KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC;
516 dma_buf_put(dma_buf);
520 uint64_t amdgpu_amdkfd_get_vram_usage(struct kgd_dev *kgd)
522 struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
523 struct ttm_resource_manager *vram_man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
525 return amdgpu_vram_mgr_usage(vram_man);
528 uint64_t amdgpu_amdkfd_get_hive_id(struct kgd_dev *kgd)
530 struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
532 return adev->gmc.xgmi.hive_id;
535 uint64_t amdgpu_amdkfd_get_unique_id(struct kgd_dev *kgd)
537 struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
539 return adev->unique_id;
542 uint8_t amdgpu_amdkfd_get_xgmi_hops_count(struct kgd_dev *dst, struct kgd_dev *src)
544 struct amdgpu_device *peer_adev = (struct amdgpu_device *)src;
545 struct amdgpu_device *adev = (struct amdgpu_device *)dst;
546 int ret = amdgpu_xgmi_get_hops_count(adev, peer_adev);
549 DRM_ERROR("amdgpu: failed to get xgmi hops count between node %d and %d. ret = %d\n",
550 adev->gmc.xgmi.physical_node_id,
551 peer_adev->gmc.xgmi.physical_node_id, ret);
557 int amdgpu_amdkfd_get_xgmi_bandwidth_mbytes(struct kgd_dev *dst, struct kgd_dev *src, bool is_min)
559 struct amdgpu_device *adev = (struct amdgpu_device *)dst, *peer_adev;
562 if (adev->asic_type != CHIP_ALDEBARAN)
566 peer_adev = (struct amdgpu_device *)src;
568 /* num links returns 0 for indirect peers since indirect route is unknown. */
569 num_links = is_min ? 1 : amdgpu_xgmi_get_num_links(adev, peer_adev);
571 DRM_ERROR("amdgpu: failed to get xgmi num links between node %d and %d. ret = %d\n",
572 adev->gmc.xgmi.physical_node_id,
573 peer_adev->gmc.xgmi.physical_node_id, num_links);
577 /* Aldebaran xGMI DPM is defeatured so assume x16 x 25Gbps for bandwidth. */
578 return (num_links * 16 * 25000)/BITS_PER_BYTE;
581 int amdgpu_amdkfd_get_pcie_bandwidth_mbytes(struct kgd_dev *dev, bool is_min)
583 struct amdgpu_device *adev = (struct amdgpu_device *)dev;
584 int num_lanes_shift = (is_min ? ffs(adev->pm.pcie_mlw_mask) :
585 fls(adev->pm.pcie_mlw_mask)) - 1;
586 int gen_speed_shift = (is_min ? ffs(adev->pm.pcie_gen_mask &
587 CAIL_PCIE_LINK_SPEED_SUPPORT_MASK) :
588 fls(adev->pm.pcie_gen_mask &
589 CAIL_PCIE_LINK_SPEED_SUPPORT_MASK)) - 1;
590 uint32_t num_lanes_mask = 1 << num_lanes_shift;
591 uint32_t gen_speed_mask = 1 << gen_speed_shift;
592 int num_lanes_factor = 0, gen_speed_mbits_factor = 0;
594 switch (num_lanes_mask) {
595 case CAIL_PCIE_LINK_WIDTH_SUPPORT_X1:
596 num_lanes_factor = 1;
598 case CAIL_PCIE_LINK_WIDTH_SUPPORT_X2:
599 num_lanes_factor = 2;
601 case CAIL_PCIE_LINK_WIDTH_SUPPORT_X4:
602 num_lanes_factor = 4;
604 case CAIL_PCIE_LINK_WIDTH_SUPPORT_X8:
605 num_lanes_factor = 8;
607 case CAIL_PCIE_LINK_WIDTH_SUPPORT_X12:
608 num_lanes_factor = 12;
610 case CAIL_PCIE_LINK_WIDTH_SUPPORT_X16:
611 num_lanes_factor = 16;
613 case CAIL_PCIE_LINK_WIDTH_SUPPORT_X32:
614 num_lanes_factor = 32;
618 switch (gen_speed_mask) {
619 case CAIL_PCIE_LINK_SPEED_SUPPORT_GEN1:
620 gen_speed_mbits_factor = 2500;
622 case CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2:
623 gen_speed_mbits_factor = 5000;
625 case CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3:
626 gen_speed_mbits_factor = 8000;
628 case CAIL_PCIE_LINK_SPEED_SUPPORT_GEN4:
629 gen_speed_mbits_factor = 16000;
631 case CAIL_PCIE_LINK_SPEED_SUPPORT_GEN5:
632 gen_speed_mbits_factor = 32000;
636 return (num_lanes_factor * gen_speed_mbits_factor)/BITS_PER_BYTE;
639 uint64_t amdgpu_amdkfd_get_mmio_remap_phys_addr(struct kgd_dev *kgd)
641 struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
643 return adev->rmmio_remap.bus_addr;
646 uint32_t amdgpu_amdkfd_get_num_gws(struct kgd_dev *kgd)
648 struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
650 return adev->gds.gws_size;
653 uint32_t amdgpu_amdkfd_get_asic_rev_id(struct kgd_dev *kgd)
655 struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
660 int amdgpu_amdkfd_get_noretry(struct kgd_dev *kgd)
662 struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
664 return adev->gmc.noretry;
667 int amdgpu_amdkfd_submit_ib(struct kgd_dev *kgd, enum kgd_engine_type engine,
668 uint32_t vmid, uint64_t gpu_addr,
669 uint32_t *ib_cmd, uint32_t ib_len)
671 struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
672 struct amdgpu_job *job;
673 struct amdgpu_ib *ib;
674 struct amdgpu_ring *ring;
675 struct dma_fence *f = NULL;
679 case KGD_ENGINE_MEC1:
680 ring = &adev->gfx.compute_ring[0];
682 case KGD_ENGINE_SDMA1:
683 ring = &adev->sdma.instance[0].ring;
685 case KGD_ENGINE_SDMA2:
686 ring = &adev->sdma.instance[1].ring;
689 pr_err("Invalid engine in IB submission: %d\n", engine);
694 ret = amdgpu_job_alloc(adev, 1, &job, NULL);
699 memset(ib, 0, sizeof(struct amdgpu_ib));
701 ib->gpu_addr = gpu_addr;
703 ib->length_dw = ib_len;
704 /* This works for NO_HWS. TODO: need to handle without knowing VMID */
707 ret = amdgpu_ib_schedule(ring, 1, ib, job, &f);
710 DRM_ERROR("amdgpu: failed to schedule IB.\n");
714 ret = dma_fence_wait(f, false);
717 amdgpu_job_free(job);
722 void amdgpu_amdkfd_set_compute_idle(struct kgd_dev *kgd, bool idle)
724 struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
726 amdgpu_dpm_switch_power_profile(adev,
727 PP_SMC_POWER_PROFILE_COMPUTE,
731 bool amdgpu_amdkfd_is_kfd_vmid(struct amdgpu_device *adev, u32 vmid)
734 return vmid >= adev->vm_manager.first_kfd_vmid;
739 int amdgpu_amdkfd_flush_gpu_tlb_vmid(struct kgd_dev *kgd, uint16_t vmid)
741 struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
743 if (adev->family == AMDGPU_FAMILY_AI) {
746 for (i = 0; i < adev->num_vmhubs; i++)
747 amdgpu_gmc_flush_gpu_tlb(adev, vmid, i, 0);
749 amdgpu_gmc_flush_gpu_tlb(adev, vmid, AMDGPU_GFXHUB_0, 0);
755 int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd, uint16_t pasid,
756 enum TLB_FLUSH_TYPE flush_type)
758 struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
759 bool all_hub = false;
761 if (adev->family == AMDGPU_FAMILY_AI)
764 return amdgpu_gmc_flush_gpu_tlb_pasid(adev, pasid, flush_type, all_hub);
767 bool amdgpu_amdkfd_have_atomics_support(struct kgd_dev *kgd)
769 struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
771 return adev->have_atomics_support;