Commit 8dc1db31 authored by Mukul Joshi's avatar Mukul Joshi Committed by Alex Deucher

drm/amdkfd: Introduce kfd_node struct (v5)

Introduce a new structure, kfd_node, which will now represent
a compute node. kfd_node is carved out of kfd_dev structure.
kfd_dev struct now will become the parent of kfd_node, and will
store common resources such as doorbells, GTT sub-alloctor etc.
kfd_node struct will store all resources specific to a compute
node, such as device queue manager, interrupt handling etc.

This is the first step in adding compute partition support in KFD.

v2: introduce kfd_node struct to gc v11 (Hawking)
v3: make reference to kfd_dev struct through kfd_node (Morris)
v4: use kfd_node instead for kfd isr/mqd functions (Morris)
v5: rebase (Alex)
Signed-off-by: default avatarMukul Joshi <mukul.joshi@amd.com>
Tested-by: default avatarAmber Lin <Amber.Lin@amd.com>
Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: default avatarHawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: default avatarMorris Zhang <Shiwu.Zhang@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 5cf16755
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "amdgpu_dma_buf.h" #include "amdgpu_dma_buf.h"
#include <uapi/linux/kfd_ioctl.h> #include <uapi/linux/kfd_ioctl.h>
#include "amdgpu_xgmi.h" #include "amdgpu_xgmi.h"
#include "kfd_priv.h"
#include "kfd_smi_events.h" #include "kfd_smi_events.h"
#include <drm/ttm/ttm_tt.h> #include <drm/ttm/ttm_tt.h>
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "amdgpu_amdkfd.h" #include "amdgpu_amdkfd.h"
#include "kfd_smi_events.h" #include "kfd_smi_events.h"
static bool cik_event_interrupt_isr(struct kfd_dev *dev, static bool cik_event_interrupt_isr(struct kfd_node *dev,
const uint32_t *ih_ring_entry, const uint32_t *ih_ring_entry,
uint32_t *patched_ihre, uint32_t *patched_ihre,
bool *patched_flag) bool *patched_flag)
...@@ -85,7 +85,7 @@ static bool cik_event_interrupt_isr(struct kfd_dev *dev, ...@@ -85,7 +85,7 @@ static bool cik_event_interrupt_isr(struct kfd_dev *dev,
!amdgpu_no_queue_eviction_on_vm_fault); !amdgpu_no_queue_eviction_on_vm_fault);
} }
static void cik_event_interrupt_wq(struct kfd_dev *dev, static void cik_event_interrupt_wq(struct kfd_node *dev,
const uint32_t *ih_ring_entry) const uint32_t *ih_ring_entry)
{ {
const struct cik_ih_ring_entry *ihre = const struct cik_ih_ring_entry *ihre =
......
...@@ -293,7 +293,7 @@ static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p, ...@@ -293,7 +293,7 @@ static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p,
void *data) void *data)
{ {
struct kfd_ioctl_create_queue_args *args = data; struct kfd_ioctl_create_queue_args *args = data;
struct kfd_dev *dev; struct kfd_node *dev;
int err = 0; int err = 0;
unsigned int queue_id; unsigned int queue_id;
struct kfd_process_device *pdd; struct kfd_process_device *pdd;
...@@ -328,7 +328,7 @@ static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p, ...@@ -328,7 +328,7 @@ static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p,
} }
if (!pdd->doorbell_index && if (!pdd->doorbell_index &&
kfd_alloc_process_doorbells(dev, &pdd->doorbell_index) < 0) { kfd_alloc_process_doorbells(dev->kfd, &pdd->doorbell_index) < 0) {
err = -ENOMEM; err = -ENOMEM;
goto err_alloc_doorbells; goto err_alloc_doorbells;
} }
...@@ -336,7 +336,7 @@ static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p, ...@@ -336,7 +336,7 @@ static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p,
/* Starting with GFX11, wptr BOs must be mapped to GART for MES to determine work /* Starting with GFX11, wptr BOs must be mapped to GART for MES to determine work
* on unmapped queues for usermode queue oversubscription (no aggregated doorbell) * on unmapped queues for usermode queue oversubscription (no aggregated doorbell)
*/ */
if (dev->shared_resources.enable_mes && if (dev->kfd->shared_resources.enable_mes &&
((dev->adev->mes.sched_version & AMDGPU_MES_API_VERSION_MASK) ((dev->adev->mes.sched_version & AMDGPU_MES_API_VERSION_MASK)
>> AMDGPU_MES_API_VERSION_SHIFT) >= 2) { >> AMDGPU_MES_API_VERSION_SHIFT) >= 2) {
struct amdgpu_bo_va_mapping *wptr_mapping; struct amdgpu_bo_va_mapping *wptr_mapping;
...@@ -887,7 +887,7 @@ static int kfd_ioctl_set_scratch_backing_va(struct file *filep, ...@@ -887,7 +887,7 @@ static int kfd_ioctl_set_scratch_backing_va(struct file *filep,
{ {
struct kfd_ioctl_set_scratch_backing_va_args *args = data; struct kfd_ioctl_set_scratch_backing_va_args *args = data;
struct kfd_process_device *pdd; struct kfd_process_device *pdd;
struct kfd_dev *dev; struct kfd_node *dev;
long err; long err;
mutex_lock(&p->mutex); mutex_lock(&p->mutex);
...@@ -1006,18 +1006,18 @@ static int kfd_ioctl_acquire_vm(struct file *filep, struct kfd_process *p, ...@@ -1006,18 +1006,18 @@ static int kfd_ioctl_acquire_vm(struct file *filep, struct kfd_process *p,
return ret; return ret;
} }
bool kfd_dev_is_large_bar(struct kfd_dev *dev) bool kfd_dev_is_large_bar(struct kfd_node *dev)
{ {
if (debug_largebar) { if (debug_largebar) {
pr_debug("Simulate large-bar allocation on non large-bar machine\n"); pr_debug("Simulate large-bar allocation on non large-bar machine\n");
return true; return true;
} }
if (dev->use_iommu_v2) if (dev->kfd->use_iommu_v2)
return false; return false;
if (dev->local_mem_info.local_mem_size_private == 0 && if (dev->kfd->local_mem_info.local_mem_size_private == 0 &&
dev->local_mem_info.local_mem_size_public > 0) dev->kfd->local_mem_info.local_mem_size_public > 0)
return true; return true;
return false; return false;
} }
...@@ -1041,7 +1041,7 @@ static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep, ...@@ -1041,7 +1041,7 @@ static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep,
struct kfd_ioctl_alloc_memory_of_gpu_args *args = data; struct kfd_ioctl_alloc_memory_of_gpu_args *args = data;
struct kfd_process_device *pdd; struct kfd_process_device *pdd;
void *mem; void *mem;
struct kfd_dev *dev; struct kfd_node *dev;
int idr_handle; int idr_handle;
long err; long err;
uint64_t offset = args->mmap_offset; uint64_t offset = args->mmap_offset;
...@@ -1105,7 +1105,7 @@ static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep, ...@@ -1105,7 +1105,7 @@ static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep,
} }
if (flags & KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL) { if (flags & KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL) {
if (args->size != kfd_doorbell_process_slice(dev)) { if (args->size != kfd_doorbell_process_slice(dev->kfd)) {
err = -EINVAL; err = -EINVAL;
goto err_unlock; goto err_unlock;
} }
...@@ -1231,7 +1231,7 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep, ...@@ -1231,7 +1231,7 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep,
struct kfd_ioctl_map_memory_to_gpu_args *args = data; struct kfd_ioctl_map_memory_to_gpu_args *args = data;
struct kfd_process_device *pdd, *peer_pdd; struct kfd_process_device *pdd, *peer_pdd;
void *mem; void *mem;
struct kfd_dev *dev; struct kfd_node *dev;
long err = 0; long err = 0;
int i; int i;
uint32_t *devices_arr = NULL; uint32_t *devices_arr = NULL;
...@@ -1405,7 +1405,7 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep, ...@@ -1405,7 +1405,7 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep,
args->n_success = i+1; args->n_success = i+1;
} }
flush_tlb = kfd_flush_tlb_after_unmap(pdd->dev); flush_tlb = kfd_flush_tlb_after_unmap(pdd->dev->kfd);
if (flush_tlb) { if (flush_tlb) {
err = amdgpu_amdkfd_gpuvm_sync_memory(pdd->dev->adev, err = amdgpu_amdkfd_gpuvm_sync_memory(pdd->dev->adev,
(struct kgd_mem *) mem, true); (struct kgd_mem *) mem, true);
...@@ -1445,7 +1445,7 @@ static int kfd_ioctl_alloc_queue_gws(struct file *filep, ...@@ -1445,7 +1445,7 @@ static int kfd_ioctl_alloc_queue_gws(struct file *filep,
int retval; int retval;
struct kfd_ioctl_alloc_queue_gws_args *args = data; struct kfd_ioctl_alloc_queue_gws_args *args = data;
struct queue *q; struct queue *q;
struct kfd_dev *dev; struct kfd_node *dev;
mutex_lock(&p->mutex); mutex_lock(&p->mutex);
q = pqm_get_user_queue(&p->pqm, args->queue_id); q = pqm_get_user_queue(&p->pqm, args->queue_id);
...@@ -1482,7 +1482,7 @@ static int kfd_ioctl_get_dmabuf_info(struct file *filep, ...@@ -1482,7 +1482,7 @@ static int kfd_ioctl_get_dmabuf_info(struct file *filep,
struct kfd_process *p, void *data) struct kfd_process *p, void *data)
{ {
struct kfd_ioctl_get_dmabuf_info_args *args = data; struct kfd_ioctl_get_dmabuf_info_args *args = data;
struct kfd_dev *dev = NULL; struct kfd_node *dev = NULL;
struct amdgpu_device *dmabuf_adev; struct amdgpu_device *dmabuf_adev;
void *metadata_buffer = NULL; void *metadata_buffer = NULL;
uint32_t flags; uint32_t flags;
...@@ -1596,7 +1596,7 @@ static int kfd_ioctl_export_dmabuf(struct file *filep, ...@@ -1596,7 +1596,7 @@ static int kfd_ioctl_export_dmabuf(struct file *filep,
struct kfd_ioctl_export_dmabuf_args *args = data; struct kfd_ioctl_export_dmabuf_args *args = data;
struct kfd_process_device *pdd; struct kfd_process_device *pdd;
struct dma_buf *dmabuf; struct dma_buf *dmabuf;
struct kfd_dev *dev; struct kfd_node *dev;
void *mem; void *mem;
int ret = 0; int ret = 0;
...@@ -2178,7 +2178,7 @@ static int criu_restore_devices(struct kfd_process *p, ...@@ -2178,7 +2178,7 @@ static int criu_restore_devices(struct kfd_process *p,
} }
for (i = 0; i < args->num_devices; i++) { for (i = 0; i < args->num_devices; i++) {
struct kfd_dev *dev; struct kfd_node *dev;
struct kfd_process_device *pdd; struct kfd_process_device *pdd;
struct file *drm_file; struct file *drm_file;
...@@ -2240,7 +2240,7 @@ static int criu_restore_devices(struct kfd_process *p, ...@@ -2240,7 +2240,7 @@ static int criu_restore_devices(struct kfd_process *p,
} }
if (!pdd->doorbell_index && if (!pdd->doorbell_index &&
kfd_alloc_process_doorbells(pdd->dev, &pdd->doorbell_index) < 0) { kfd_alloc_process_doorbells(pdd->dev->kfd, &pdd->doorbell_index) < 0) {
ret = -ENOMEM; ret = -ENOMEM;
goto exit; goto exit;
} }
...@@ -2268,7 +2268,8 @@ static int criu_restore_memory_of_gpu(struct kfd_process_device *pdd, ...@@ -2268,7 +2268,8 @@ static int criu_restore_memory_of_gpu(struct kfd_process_device *pdd,
u64 offset; u64 offset;
if (bo_bucket->alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL) { if (bo_bucket->alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL) {
if (bo_bucket->size != kfd_doorbell_process_slice(pdd->dev)) if (bo_bucket->size !=
kfd_doorbell_process_slice(pdd->dev->kfd))
return -EINVAL; return -EINVAL;
offset = kfd_get_process_doorbells(pdd); offset = kfd_get_process_doorbells(pdd);
...@@ -2350,7 +2351,7 @@ static int criu_restore_bo(struct kfd_process *p, ...@@ -2350,7 +2351,7 @@ static int criu_restore_bo(struct kfd_process *p,
/* now map these BOs to GPU/s */ /* now map these BOs to GPU/s */
for (j = 0; j < p->n_pdds; j++) { for (j = 0; j < p->n_pdds; j++) {
struct kfd_dev *peer; struct kfd_node *peer;
struct kfd_process_device *peer_pdd; struct kfd_process_device *peer_pdd;
if (!bo_priv->mapped_gpuids[j]) if (!bo_priv->mapped_gpuids[j])
...@@ -2947,7 +2948,7 @@ static long kfd_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) ...@@ -2947,7 +2948,7 @@ static long kfd_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
return retcode; return retcode;
} }
static int kfd_mmio_mmap(struct kfd_dev *dev, struct kfd_process *process, static int kfd_mmio_mmap(struct kfd_node *dev, struct kfd_process *process,
struct vm_area_struct *vma) struct vm_area_struct *vma)
{ {
phys_addr_t address; phys_addr_t address;
...@@ -2981,7 +2982,7 @@ static int kfd_mmio_mmap(struct kfd_dev *dev, struct kfd_process *process, ...@@ -2981,7 +2982,7 @@ static int kfd_mmio_mmap(struct kfd_dev *dev, struct kfd_process *process,
static int kfd_mmap(struct file *filp, struct vm_area_struct *vma) static int kfd_mmap(struct file *filp, struct vm_area_struct *vma)
{ {
struct kfd_process *process; struct kfd_process *process;
struct kfd_dev *dev = NULL; struct kfd_node *dev = NULL;
unsigned long mmap_offset; unsigned long mmap_offset;
unsigned int gpu_id; unsigned int gpu_id;
......
...@@ -1405,7 +1405,7 @@ static int kfd_fill_gpu_cache_info_from_gfx_config(struct kfd_dev *kdev, ...@@ -1405,7 +1405,7 @@ static int kfd_fill_gpu_cache_info_from_gfx_config(struct kfd_dev *kdev,
return i; return i;
} }
int kfd_get_gpu_cache_info(struct kfd_dev *kdev, struct kfd_gpu_cache_info **pcache_info) int kfd_get_gpu_cache_info(struct kfd_node *kdev, struct kfd_gpu_cache_info **pcache_info)
{ {
int num_of_cache_types = 0; int num_of_cache_types = 0;
...@@ -1524,7 +1524,7 @@ int kfd_get_gpu_cache_info(struct kfd_dev *kdev, struct kfd_gpu_cache_info **pca ...@@ -1524,7 +1524,7 @@ int kfd_get_gpu_cache_info(struct kfd_dev *kdev, struct kfd_gpu_cache_info **pca
case IP_VERSION(11, 0, 3): case IP_VERSION(11, 0, 3):
case IP_VERSION(11, 0, 4): case IP_VERSION(11, 0, 4):
num_of_cache_types = num_of_cache_types =
kfd_fill_gpu_cache_info_from_gfx_config(kdev, *pcache_info); kfd_fill_gpu_cache_info_from_gfx_config(kdev->kfd, *pcache_info);
break; break;
default: default:
*pcache_info = dummy_cache_info; *pcache_info = dummy_cache_info;
...@@ -1858,7 +1858,7 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size) ...@@ -1858,7 +1858,7 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size)
} }
static int kfd_fill_gpu_memory_affinity(int *avail_size, static int kfd_fill_gpu_memory_affinity(int *avail_size,
struct kfd_dev *kdev, uint8_t type, uint64_t size, struct kfd_node *kdev, uint8_t type, uint64_t size,
struct crat_subtype_memory *sub_type_hdr, struct crat_subtype_memory *sub_type_hdr,
uint32_t proximity_domain, uint32_t proximity_domain,
const struct kfd_local_mem_info *local_mem_info) const struct kfd_local_mem_info *local_mem_info)
...@@ -1887,7 +1887,7 @@ static int kfd_fill_gpu_memory_affinity(int *avail_size, ...@@ -1887,7 +1887,7 @@ static int kfd_fill_gpu_memory_affinity(int *avail_size,
} }
#ifdef CONFIG_ACPI_NUMA #ifdef CONFIG_ACPI_NUMA
static void kfd_find_numa_node_in_srat(struct kfd_dev *kdev) static void kfd_find_numa_node_in_srat(struct kfd_node *kdev)
{ {
struct acpi_table_header *table_header = NULL; struct acpi_table_header *table_header = NULL;
struct acpi_subtable_header *sub_header = NULL; struct acpi_subtable_header *sub_header = NULL;
...@@ -1982,7 +1982,7 @@ static void kfd_find_numa_node_in_srat(struct kfd_dev *kdev) ...@@ -1982,7 +1982,7 @@ static void kfd_find_numa_node_in_srat(struct kfd_dev *kdev)
* Return 0 if successful else return -ve value * Return 0 if successful else return -ve value
*/ */
static int kfd_fill_gpu_direct_io_link_to_cpu(int *avail_size, static int kfd_fill_gpu_direct_io_link_to_cpu(int *avail_size,
struct kfd_dev *kdev, struct kfd_node *kdev,
struct crat_subtype_iolink *sub_type_hdr, struct crat_subtype_iolink *sub_type_hdr,
uint32_t proximity_domain) uint32_t proximity_domain)
{ {
...@@ -2044,8 +2044,8 @@ static int kfd_fill_gpu_direct_io_link_to_cpu(int *avail_size, ...@@ -2044,8 +2044,8 @@ static int kfd_fill_gpu_direct_io_link_to_cpu(int *avail_size,
} }
static int kfd_fill_gpu_xgmi_link_to_gpu(int *avail_size, static int kfd_fill_gpu_xgmi_link_to_gpu(int *avail_size,
struct kfd_dev *kdev, struct kfd_node *kdev,
struct kfd_dev *peer_kdev, struct kfd_node *peer_kdev,
struct crat_subtype_iolink *sub_type_hdr, struct crat_subtype_iolink *sub_type_hdr,
uint32_t proximity_domain_from, uint32_t proximity_domain_from,
uint32_t proximity_domain_to) uint32_t proximity_domain_to)
...@@ -2081,7 +2081,7 @@ static int kfd_fill_gpu_xgmi_link_to_gpu(int *avail_size, ...@@ -2081,7 +2081,7 @@ static int kfd_fill_gpu_xgmi_link_to_gpu(int *avail_size,
* [OUT] actual size of data filled in crat_image * [OUT] actual size of data filled in crat_image
*/ */
static int kfd_create_vcrat_image_gpu(void *pcrat_image, static int kfd_create_vcrat_image_gpu(void *pcrat_image,
size_t *size, struct kfd_dev *kdev, size_t *size, struct kfd_node *kdev,
uint32_t proximity_domain) uint32_t proximity_domain)
{ {
struct crat_header *crat_table = (struct crat_header *)pcrat_image; struct crat_header *crat_table = (struct crat_header *)pcrat_image;
...@@ -2153,7 +2153,7 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image, ...@@ -2153,7 +2153,7 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image,
/* Check if this node supports IOMMU. During parsing this flag will /* Check if this node supports IOMMU. During parsing this flag will
* translate to HSA_CAP_ATS_PRESENT * translate to HSA_CAP_ATS_PRESENT
*/ */
if (!kfd_iommu_check_device(kdev)) if (!kfd_iommu_check_device(kdev->kfd))
cu->hsa_capability |= CRAT_CU_FLAGS_IOMMU_PRESENT; cu->hsa_capability |= CRAT_CU_FLAGS_IOMMU_PRESENT;
crat_table->length += sub_type_hdr->length; crat_table->length += sub_type_hdr->length;
...@@ -2164,7 +2164,7 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image, ...@@ -2164,7 +2164,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.
*/ */
local_mem_info = kdev->local_mem_info; local_mem_info = kdev->kfd->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);
...@@ -2216,12 +2216,12 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image, ...@@ -2216,12 +2216,12 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image,
* (from other GPU to this GPU) will be added * (from other GPU to this GPU) will be added
* in kfd_parse_subtype_iolink. * in kfd_parse_subtype_iolink.
*/ */
if (kdev->hive_id) { if (kdev->kfd->hive_id) {
for (nid = 0; nid < proximity_domain; ++nid) { for (nid = 0; nid < proximity_domain; ++nid) {
peer_dev = kfd_topology_device_by_proximity_domain_no_lock(nid); peer_dev = kfd_topology_device_by_proximity_domain_no_lock(nid);
if (!peer_dev->gpu) if (!peer_dev->gpu)
continue; continue;
if (peer_dev->gpu->hive_id != kdev->hive_id) if (peer_dev->gpu->kfd->hive_id != kdev->kfd->hive_id)
continue; continue;
sub_type_hdr = (typeof(sub_type_hdr))( sub_type_hdr = (typeof(sub_type_hdr))(
(char *)sub_type_hdr + (char *)sub_type_hdr +
...@@ -2255,12 +2255,12 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image, ...@@ -2255,12 +2255,12 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image,
* (COMPUTE_UNIT_CPU | COMPUTE_UNIT_GPU) - Create VCRAT for APU * (COMPUTE_UNIT_CPU | COMPUTE_UNIT_GPU) - Create VCRAT for APU
* -- this option is not currently implemented. * -- this option is not currently implemented.
* The assumption is that all AMD APUs will have CRAT * The assumption is that all AMD APUs will have CRAT
* @kdev: Valid kfd_device required if flags contain COMPUTE_UNIT_GPU * @kdev: Valid kfd_node required if flags contain COMPUTE_UNIT_GPU
* *
* Return 0 if successful else return -ve value * Return 0 if successful else return -ve value
*/ */
int kfd_create_crat_image_virtual(void **crat_image, size_t *size, int kfd_create_crat_image_virtual(void **crat_image, size_t *size,
int flags, struct kfd_dev *kdev, int flags, struct kfd_node *kdev,
uint32_t proximity_domain) uint32_t proximity_domain)
{ {
void *pcrat_image = NULL; void *pcrat_image = NULL;
......
...@@ -293,7 +293,7 @@ struct crat_subtype_generic { ...@@ -293,7 +293,7 @@ struct crat_subtype_generic {
#pragma pack() #pragma pack()
struct kfd_dev; struct kfd_node;
/* Static table to describe GPU Cache information */ /* Static table to describe GPU Cache information */
struct kfd_gpu_cache_info { struct kfd_gpu_cache_info {
...@@ -305,14 +305,14 @@ struct kfd_gpu_cache_info { ...@@ -305,14 +305,14 @@ struct kfd_gpu_cache_info {
*/ */
uint32_t num_cu_shared; uint32_t num_cu_shared;
}; };
int kfd_get_gpu_cache_info(struct kfd_dev *kdev, struct kfd_gpu_cache_info **pcache_info); int kfd_get_gpu_cache_info(struct kfd_node *kdev, struct kfd_gpu_cache_info **pcache_info);
int kfd_create_crat_image_acpi(void **crat_image, size_t *size); int kfd_create_crat_image_acpi(void **crat_image, size_t *size);
void kfd_destroy_crat_image(void *crat_image); void kfd_destroy_crat_image(void *crat_image);
int kfd_parse_crat_table(void *crat_image, struct list_head *device_list, int kfd_parse_crat_table(void *crat_image, struct list_head *device_list,
uint32_t proximity_domain); uint32_t proximity_domain);
int kfd_create_crat_image_virtual(void **crat_image, size_t *size, int kfd_create_crat_image_virtual(void **crat_image, size_t *size,
int flags, struct kfd_dev *kdev, int flags, struct kfd_node *kdev,
uint32_t proximity_domain); uint32_t proximity_domain);
#endif /* KFD_CRAT_H_INCLUDED */ #endif /* KFD_CRAT_H_INCLUDED */
...@@ -43,7 +43,7 @@ static int kfd_debugfs_hang_hws_read(struct seq_file *m, void *data) ...@@ -43,7 +43,7 @@ static int kfd_debugfs_hang_hws_read(struct seq_file *m, void *data)
static ssize_t kfd_debugfs_hang_hws_write(struct file *file, static ssize_t kfd_debugfs_hang_hws_write(struct file *file,
const char __user *user_buf, size_t size, loff_t *ppos) const char __user *user_buf, size_t size, loff_t *ppos)
{ {
struct kfd_dev *dev; struct kfd_node *dev;
char tmp[16]; char tmp[16];
uint32_t gpu_id; uint32_t gpu_id;
int ret = -EINVAL; int ret = -EINVAL;
......
This diff is collapsed.
...@@ -207,7 +207,7 @@ struct device_queue_manager_asic_ops { ...@@ -207,7 +207,7 @@ struct device_queue_manager_asic_ops {
struct queue *q, struct queue *q,
struct qcm_process_device *qpd); struct qcm_process_device *qpd);
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_node *dev);
}; };
/** /**
...@@ -228,7 +228,7 @@ struct device_queue_manager { ...@@ -228,7 +228,7 @@ struct device_queue_manager {
struct mqd_manager *mqd_mgrs[KFD_MQD_TYPE_MAX]; struct mqd_manager *mqd_mgrs[KFD_MQD_TYPE_MAX];
struct packet_manager packet_mgr; struct packet_manager packet_mgr;
struct kfd_dev *dev; struct kfd_node *dev;
struct mutex lock_hidden; /* use dqm_lock/unlock(dqm) */ struct mutex lock_hidden; /* use dqm_lock/unlock(dqm) */
struct list_head queues; struct list_head queues;
unsigned int saved_flags; unsigned int saved_flags;
......
...@@ -60,10 +60,10 @@ static int update_qpd_v9(struct device_queue_manager *dqm, ...@@ -60,10 +60,10 @@ static int update_qpd_v9(struct device_queue_manager *dqm,
qpd->sh_mem_config = SH_MEM_ALIGNMENT_MODE_UNALIGNED << qpd->sh_mem_config = SH_MEM_ALIGNMENT_MODE_UNALIGNED <<
SH_MEM_CONFIG__ALIGNMENT_MODE__SHIFT; SH_MEM_CONFIG__ALIGNMENT_MODE__SHIFT;
if (dqm->dev->noretry && !dqm->dev->use_iommu_v2) if (dqm->dev->kfd->noretry && !dqm->dev->kfd->use_iommu_v2)
qpd->sh_mem_config |= 1 << SH_MEM_CONFIG__RETRY_DISABLE__SHIFT; qpd->sh_mem_config |= 1 << SH_MEM_CONFIG__RETRY_DISABLE__SHIFT;
if (KFD_GC_VERSION(dqm->dev) == IP_VERSION(9, 4, 3)) if (KFD_GC_VERSION(dqm->dev->kfd) == IP_VERSION(9, 4, 3))
qpd->sh_mem_config |= qpd->sh_mem_config |=
(1 << SH_MEM_CONFIG__F8_MODE__SHIFT); (1 << SH_MEM_CONFIG__F8_MODE__SHIFT);
......
...@@ -138,7 +138,7 @@ void kfd_doorbell_fini(struct kfd_dev *kfd) ...@@ -138,7 +138,7 @@ void kfd_doorbell_fini(struct kfd_dev *kfd)
iounmap(kfd->doorbell_kernel_ptr); iounmap(kfd->doorbell_kernel_ptr);
} }
int kfd_doorbell_mmap(struct kfd_dev *dev, struct kfd_process *process, int kfd_doorbell_mmap(struct kfd_node *dev, struct kfd_process *process,
struct vm_area_struct *vma) struct vm_area_struct *vma)
{ {
phys_addr_t address; phys_addr_t address;
...@@ -148,7 +148,7 @@ int kfd_doorbell_mmap(struct kfd_dev *dev, struct kfd_process *process, ...@@ -148,7 +148,7 @@ int kfd_doorbell_mmap(struct kfd_dev *dev, struct kfd_process *process,
* For simplicitly we only allow mapping of the entire doorbell * For simplicitly we only allow mapping of the entire doorbell
* allocation of a single device & process. * allocation of a single device & process.
*/ */
if (vma->vm_end - vma->vm_start != kfd_doorbell_process_slice(dev)) if (vma->vm_end - vma->vm_start != kfd_doorbell_process_slice(dev->kfd))
return -EINVAL; return -EINVAL;
pdd = kfd_get_process_device_data(dev, process); pdd = kfd_get_process_device_data(dev, process);
...@@ -170,13 +170,13 @@ int kfd_doorbell_mmap(struct kfd_dev *dev, struct kfd_process *process, ...@@ -170,13 +170,13 @@ int kfd_doorbell_mmap(struct kfd_dev *dev, struct kfd_process *process,
" vm_flags == 0x%04lX\n" " vm_flags == 0x%04lX\n"
" size == 0x%04lX\n", " size == 0x%04lX\n",
(unsigned long long) vma->vm_start, address, vma->vm_flags, (unsigned long long) vma->vm_start, address, vma->vm_flags,
kfd_doorbell_process_slice(dev)); kfd_doorbell_process_slice(dev->kfd));
return io_remap_pfn_range(vma, return io_remap_pfn_range(vma,
vma->vm_start, vma->vm_start,
address >> PAGE_SHIFT, address >> PAGE_SHIFT,
kfd_doorbell_process_slice(dev), kfd_doorbell_process_slice(dev->kfd),
vma->vm_page_prot); vma->vm_page_prot);
} }
...@@ -278,14 +278,14 @@ uint64_t kfd_get_number_elems(struct kfd_dev *kfd) ...@@ -278,14 +278,14 @@ uint64_t kfd_get_number_elems(struct kfd_dev *kfd)
phys_addr_t kfd_get_process_doorbells(struct kfd_process_device *pdd) phys_addr_t kfd_get_process_doorbells(struct kfd_process_device *pdd)
{ {
if (!pdd->doorbell_index) { if (!pdd->doorbell_index) {
int r = kfd_alloc_process_doorbells(pdd->dev, int r = kfd_alloc_process_doorbells(pdd->dev->kfd,
&pdd->doorbell_index); &pdd->doorbell_index);
if (r < 0) if (r < 0)
return 0; return 0;
} }
return pdd->dev->doorbell_base + return pdd->dev->kfd->doorbell_base +
pdd->doorbell_index * kfd_doorbell_process_slice(pdd->dev); pdd->doorbell_index * kfd_doorbell_process_slice(pdd->dev->kfd);
} }
int kfd_alloc_process_doorbells(struct kfd_dev *kfd, unsigned int *doorbell_index) int kfd_alloc_process_doorbells(struct kfd_dev *kfd, unsigned int *doorbell_index)
......
...@@ -348,7 +348,7 @@ static int kfd_event_page_set(struct kfd_process *p, void *kernel_address, ...@@ -348,7 +348,7 @@ static int kfd_event_page_set(struct kfd_process *p, void *kernel_address,
int kfd_kmap_event_page(struct kfd_process *p, uint64_t event_page_offset) int kfd_kmap_event_page(struct kfd_process *p, uint64_t event_page_offset)
{ {
struct kfd_dev *kfd; struct kfd_node *kfd;
struct kfd_process_device *pdd; struct kfd_process_device *pdd;
void *mem, *kern_addr; void *mem, *kern_addr;
uint64_t size; uint64_t size;
...@@ -1125,7 +1125,7 @@ static void lookup_events_by_type_and_signal(struct kfd_process *p, ...@@ -1125,7 +1125,7 @@ static void lookup_events_by_type_and_signal(struct kfd_process *p,
} }
#ifdef KFD_SUPPORT_IOMMU_V2 #ifdef KFD_SUPPORT_IOMMU_V2
void kfd_signal_iommu_event(struct kfd_dev *dev, u32 pasid, void kfd_signal_iommu_event(struct kfd_node *dev, u32 pasid,
unsigned long address, bool is_write_requested, unsigned long address, bool is_write_requested,
bool is_execute_requested) bool is_execute_requested)
{ {
...@@ -1221,8 +1221,8 @@ void kfd_signal_hw_exception_event(u32 pasid) ...@@ -1221,8 +1221,8 @@ void kfd_signal_hw_exception_event(u32 pasid)
kfd_unref_process(p); kfd_unref_process(p);
} }
void kfd_signal_vm_fault_event(struct kfd_dev *dev, u32 pasid, void kfd_signal_vm_fault_event(struct kfd_node *dev, u32 pasid,
struct kfd_vm_fault_info *info) struct kfd_vm_fault_info *info)
{ {
struct kfd_event *ev; struct kfd_event *ev;
uint32_t id; uint32_t id;
...@@ -1269,7 +1269,7 @@ void kfd_signal_vm_fault_event(struct kfd_dev *dev, u32 pasid, ...@@ -1269,7 +1269,7 @@ void kfd_signal_vm_fault_event(struct kfd_dev *dev, u32 pasid,
kfd_unref_process(p); kfd_unref_process(p);
} }
void kfd_signal_reset_event(struct kfd_dev *dev) void kfd_signal_reset_event(struct kfd_node *dev)
{ {
struct kfd_hsa_hw_exception_data hw_exception_data; struct kfd_hsa_hw_exception_data hw_exception_data;
struct kfd_hsa_memory_exception_data memory_exception_data; struct kfd_hsa_memory_exception_data memory_exception_data;
...@@ -1325,7 +1325,7 @@ void kfd_signal_reset_event(struct kfd_dev *dev) ...@@ -1325,7 +1325,7 @@ void kfd_signal_reset_event(struct kfd_dev *dev)
srcu_read_unlock(&kfd_processes_srcu, idx); srcu_read_unlock(&kfd_processes_srcu, idx);
} }
void kfd_signal_poison_consumed_event(struct kfd_dev *dev, u32 pasid) void kfd_signal_poison_consumed_event(struct kfd_node *dev, u32 pasid)
{ {
struct kfd_process *p = kfd_lookup_process_by_pasid(pasid); struct kfd_process *p = kfd_lookup_process_by_pasid(pasid);
struct kfd_hsa_memory_exception_data memory_exception_data; struct kfd_hsa_memory_exception_data memory_exception_data;
......
...@@ -322,21 +322,21 @@ static void kfd_init_apertures_vi(struct kfd_process_device *pdd, uint8_t id) ...@@ -322,21 +322,21 @@ static void kfd_init_apertures_vi(struct kfd_process_device *pdd, uint8_t id)
pdd->lds_base = MAKE_LDS_APP_BASE_VI(); pdd->lds_base = MAKE_LDS_APP_BASE_VI();
pdd->lds_limit = MAKE_LDS_APP_LIMIT(pdd->lds_base); pdd->lds_limit = MAKE_LDS_APP_LIMIT(pdd->lds_base);
if (!pdd->dev->use_iommu_v2) { if (!pdd->dev->kfd->use_iommu_v2) {
/* dGPUs: SVM aperture starting at 0 /* dGPUs: SVM aperture starting at 0
* with small reserved space for kernel. * with small reserved space for kernel.
* Set them to CANONICAL addresses. * Set them to CANONICAL addresses.
*/ */
pdd->gpuvm_base = SVM_USER_BASE; pdd->gpuvm_base = SVM_USER_BASE;
pdd->gpuvm_limit = pdd->gpuvm_limit =
pdd->dev->shared_resources.gpuvm_size - 1; pdd->dev->kfd->shared_resources.gpuvm_size - 1;
} else { } else {
/* set them to non CANONICAL addresses, and no SVM is /* set them to non CANONICAL addresses, and no SVM is
* allocated. * allocated.
*/ */
pdd->gpuvm_base = MAKE_GPUVM_APP_BASE_VI(id + 1); pdd->gpuvm_base = MAKE_GPUVM_APP_BASE_VI(id + 1);
pdd->gpuvm_limit = MAKE_GPUVM_APP_LIMIT(pdd->gpuvm_base, pdd->gpuvm_limit = MAKE_GPUVM_APP_LIMIT(pdd->gpuvm_base,
pdd->dev->shared_resources.gpuvm_size); pdd->dev->kfd->shared_resources.gpuvm_size);
} }
pdd->scratch_base = MAKE_SCRATCH_APP_BASE_VI(); pdd->scratch_base = MAKE_SCRATCH_APP_BASE_VI();
...@@ -356,7 +356,7 @@ static void kfd_init_apertures_v9(struct kfd_process_device *pdd, uint8_t id) ...@@ -356,7 +356,7 @@ static void kfd_init_apertures_v9(struct kfd_process_device *pdd, uint8_t id)
*/ */
pdd->gpuvm_base = SVM_USER_BASE; pdd->gpuvm_base = SVM_USER_BASE;
pdd->gpuvm_limit = pdd->gpuvm_limit =
pdd->dev->shared_resources.gpuvm_size - 1; pdd->dev->kfd->shared_resources.gpuvm_size - 1;
pdd->scratch_base = MAKE_SCRATCH_APP_BASE_V9(); pdd->scratch_base = MAKE_SCRATCH_APP_BASE_V9();
pdd->scratch_limit = MAKE_SCRATCH_APP_LIMIT(pdd->scratch_base); pdd->scratch_limit = MAKE_SCRATCH_APP_LIMIT(pdd->scratch_base);
...@@ -365,7 +365,7 @@ static void kfd_init_apertures_v9(struct kfd_process_device *pdd, uint8_t id) ...@@ -365,7 +365,7 @@ static void kfd_init_apertures_v9(struct kfd_process_device *pdd, uint8_t id)
int kfd_init_apertures(struct kfd_process *process) int kfd_init_apertures(struct kfd_process *process)
{ {
uint8_t id = 0; uint8_t id = 0;
struct kfd_dev *dev; struct kfd_node *dev;
struct kfd_process_device *pdd; struct kfd_process_device *pdd;
/*Iterating over all devices*/ /*Iterating over all devices*/
...@@ -417,7 +417,7 @@ int kfd_init_apertures(struct kfd_process *process) ...@@ -417,7 +417,7 @@ int kfd_init_apertures(struct kfd_process *process)
} }
} }
if (!dev->use_iommu_v2) { if (!dev->kfd->use_iommu_v2) {
/* dGPUs: the reserved space for kernel /* dGPUs: the reserved space for kernel
* before SVM * before SVM
*/ */
......
...@@ -187,7 +187,7 @@ static void print_sq_intr_info_error(uint32_t context_id0, uint32_t context_id1) ...@@ -187,7 +187,7 @@ static void print_sq_intr_info_error(uint32_t context_id0, uint32_t context_id1)
REG_GET_FIELD(context_id0, SQ_INTERRUPT_WORD_ERROR_CTXID1, WGP_ID)); REG_GET_FIELD(context_id0, SQ_INTERRUPT_WORD_ERROR_CTXID1, WGP_ID));
} }
static void event_interrupt_poison_consumption_v11(struct kfd_dev *dev, static void event_interrupt_poison_consumption_v11(struct kfd_node *dev,
uint16_t pasid, uint16_t source_id) uint16_t pasid, uint16_t source_id)
{ {
int ret = -EINVAL; int ret = -EINVAL;
...@@ -225,7 +225,7 @@ static void event_interrupt_poison_consumption_v11(struct kfd_dev *dev, ...@@ -225,7 +225,7 @@ static void event_interrupt_poison_consumption_v11(struct kfd_dev *dev,
amdgpu_amdkfd_ras_poison_consumption_handler(dev->adev, true); amdgpu_amdkfd_ras_poison_consumption_handler(dev->adev, true);
} }
static bool event_interrupt_isr_v11(struct kfd_dev *dev, static bool event_interrupt_isr_v11(struct kfd_node *dev,
const uint32_t *ih_ring_entry, const uint32_t *ih_ring_entry,
uint32_t *patched_ihre, uint32_t *patched_ihre,
bool *patched_flag) bool *patched_flag)
...@@ -274,7 +274,7 @@ static bool event_interrupt_isr_v11(struct kfd_dev *dev, ...@@ -274,7 +274,7 @@ static bool event_interrupt_isr_v11(struct kfd_dev *dev,
!amdgpu_no_queue_eviction_on_vm_fault); !amdgpu_no_queue_eviction_on_vm_fault);
} }
static void event_interrupt_wq_v11(struct kfd_dev *dev, static void event_interrupt_wq_v11(struct kfd_node *dev,
const uint32_t *ih_ring_entry) const uint32_t *ih_ring_entry)
{ {
uint16_t source_id, client_id, ring_id, pasid, vmid; uint16_t source_id, client_id, ring_id, pasid, vmid;
......
...@@ -90,7 +90,7 @@ enum SQ_INTERRUPT_ERROR_TYPE { ...@@ -90,7 +90,7 @@ enum SQ_INTERRUPT_ERROR_TYPE {
#define KFD_SQ_INT_DATA__ERR_TYPE_MASK 0xF00000 #define KFD_SQ_INT_DATA__ERR_TYPE_MASK 0xF00000
#define KFD_SQ_INT_DATA__ERR_TYPE__SHIFT 20 #define KFD_SQ_INT_DATA__ERR_TYPE__SHIFT 20
static void event_interrupt_poison_consumption_v9(struct kfd_dev *dev, static void event_interrupt_poison_consumption_v9(struct kfd_node *dev,
uint16_t pasid, uint16_t client_id) uint16_t pasid, uint16_t client_id)
{ {
int old_poison, ret = -EINVAL; int old_poison, ret = -EINVAL;
...@@ -160,7 +160,7 @@ static bool context_id_expected(struct kfd_dev *dev) ...@@ -160,7 +160,7 @@ static bool context_id_expected(struct kfd_dev *dev)
} }
} }
static bool event_interrupt_isr_v9(struct kfd_dev *dev, static bool event_interrupt_isr_v9(struct kfd_node *dev,
const uint32_t *ih_ring_entry, const uint32_t *ih_ring_entry,
uint32_t *patched_ihre, uint32_t *patched_ihre,
bool *patched_flag) bool *patched_flag)
...@@ -206,7 +206,7 @@ static bool event_interrupt_isr_v9(struct kfd_dev *dev, ...@@ -206,7 +206,7 @@ static bool event_interrupt_isr_v9(struct kfd_dev *dev,
*patched_flag = true; *patched_flag = true;
memcpy(patched_ihre, ih_ring_entry, memcpy(patched_ihre, ih_ring_entry,
dev->device_info.ih_ring_entry_size); dev->kfd->device_info.ih_ring_entry_size);
pasid = dev->dqm->vmid_pasid[vmid]; pasid = dev->dqm->vmid_pasid[vmid];
...@@ -235,7 +235,7 @@ static bool event_interrupt_isr_v9(struct kfd_dev *dev, ...@@ -235,7 +235,7 @@ static bool event_interrupt_isr_v9(struct kfd_dev *dev,
uint32_t context_id = uint32_t context_id =
SOC15_CONTEXT_ID0_FROM_IH_ENTRY(ih_ring_entry); SOC15_CONTEXT_ID0_FROM_IH_ENTRY(ih_ring_entry);
if (context_id == 0 && context_id_expected(dev)) if (context_id == 0 && context_id_expected(dev->kfd))
return false; return false;
} }
...@@ -253,7 +253,7 @@ static bool event_interrupt_isr_v9(struct kfd_dev *dev, ...@@ -253,7 +253,7 @@ static bool event_interrupt_isr_v9(struct kfd_dev *dev,
!amdgpu_no_queue_eviction_on_vm_fault); !amdgpu_no_queue_eviction_on_vm_fault);
} }
static void event_interrupt_wq_v9(struct kfd_dev *dev, static void event_interrupt_wq_v9(struct kfd_node *dev,
const uint32_t *ih_ring_entry) const uint32_t *ih_ring_entry)
{ {
uint16_t source_id, client_id, pasid, vmid; uint16_t source_id, client_id, pasid, vmid;
......
...@@ -50,29 +50,29 @@ ...@@ -50,29 +50,29 @@
static void interrupt_wq(struct work_struct *); static void interrupt_wq(struct work_struct *);
int kfd_interrupt_init(struct kfd_dev *kfd) int kfd_interrupt_init(struct kfd_node *node)
{ {
int r; int r;
r = kfifo_alloc(&kfd->ih_fifo, r = kfifo_alloc(&node->ih_fifo,
KFD_IH_NUM_ENTRIES * kfd->device_info.ih_ring_entry_size, KFD_IH_NUM_ENTRIES * node->kfd->device_info.ih_ring_entry_size,
GFP_KERNEL); GFP_KERNEL);
if (r) { if (r) {
dev_err(kfd->adev->dev, "Failed to allocate IH fifo\n"); dev_err(node->adev->dev, "Failed to allocate IH fifo\n");
return r; return r;
} }
kfd->ih_wq = alloc_workqueue("KFD IH", WQ_HIGHPRI, 1); node->ih_wq = alloc_workqueue("KFD IH", WQ_HIGHPRI, 1);
if (unlikely(!kfd->ih_wq)) { if (unlikely(!node->ih_wq)) {
kfifo_free(&kfd->ih_fifo); kfifo_free(&node->ih_fifo);
dev_err(kfd->adev->dev, "Failed to allocate KFD IH workqueue\n"); dev_err(node->adev->dev, "Failed to allocate KFD IH workqueue\n");
return -ENOMEM; return -ENOMEM;
} }
spin_lock_init(&kfd->interrupt_lock); spin_lock_init(&node->interrupt_lock);
INIT_WORK(&kfd->interrupt_work, interrupt_wq); INIT_WORK(&node->interrupt_work, interrupt_wq);
kfd->interrupts_active = true; node->interrupts_active = true;
/* /*
* After this function returns, the interrupt will be enabled. This * After this function returns, the interrupt will be enabled. This
...@@ -84,7 +84,7 @@ int kfd_interrupt_init(struct kfd_dev *kfd) ...@@ -84,7 +84,7 @@ int kfd_interrupt_init(struct kfd_dev *kfd)
return 0; return 0;
} }
void kfd_interrupt_exit(struct kfd_dev *kfd) void kfd_interrupt_exit(struct kfd_node *node)
{ {
/* /*
* Stop the interrupt handler from writing to the ring and scheduling * Stop the interrupt handler from writing to the ring and scheduling
...@@ -93,31 +93,31 @@ void kfd_interrupt_exit(struct kfd_dev *kfd) ...@@ -93,31 +93,31 @@ void kfd_interrupt_exit(struct kfd_dev *kfd)
*/ */
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&kfd->interrupt_lock, flags); spin_lock_irqsave(&node->interrupt_lock, flags);
kfd->interrupts_active = false; node->interrupts_active = false;
spin_unlock_irqrestore(&kfd->interrupt_lock, flags); spin_unlock_irqrestore(&node->interrupt_lock, flags);
/* /*
* flush_work ensures that there are no outstanding * flush_work ensures that there are no outstanding
* work-queue items that will access interrupt_ring. New work items * work-queue items that will access interrupt_ring. New work items
* can't be created because we stopped interrupt handling above. * can't be created because we stopped interrupt handling above.
*/ */
flush_workqueue(kfd->ih_wq); flush_workqueue(node->ih_wq);
kfifo_free(&kfd->ih_fifo); kfifo_free(&node->ih_fifo);
} }
/* /*
* Assumption: single reader/writer. This function is not re-entrant * Assumption: single reader/writer. This function is not re-entrant
*/ */
bool enqueue_ih_ring_entry(struct kfd_dev *kfd, const void *ih_ring_entry) bool enqueue_ih_ring_entry(struct kfd_node *node, const void *ih_ring_entry)
{ {
int count; int count;
count = kfifo_in(&kfd->ih_fifo, ih_ring_entry, count = kfifo_in(&node->ih_fifo, ih_ring_entry,
kfd->device_info.ih_ring_entry_size); node->kfd->device_info.ih_ring_entry_size);
if (count != kfd->device_info.ih_ring_entry_size) { if (count != node->kfd->device_info.ih_ring_entry_size) {
dev_dbg_ratelimited(kfd->adev->dev, dev_dbg_ratelimited(node->adev->dev,
"Interrupt ring overflow, dropping interrupt %d\n", "Interrupt ring overflow, dropping interrupt %d\n",
count); count);
return false; return false;
...@@ -129,32 +129,32 @@ bool enqueue_ih_ring_entry(struct kfd_dev *kfd, const void *ih_ring_entry) ...@@ -129,32 +129,32 @@ bool enqueue_ih_ring_entry(struct kfd_dev *kfd, const void *ih_ring_entry)
/* /*
* Assumption: single reader/writer. This function is not re-entrant * Assumption: single reader/writer. This function is not re-entrant
*/ */
static bool dequeue_ih_ring_entry(struct kfd_dev *kfd, void *ih_ring_entry) static bool dequeue_ih_ring_entry(struct kfd_node *node, void *ih_ring_entry)
{ {
int count; int count;
count = kfifo_out(&kfd->ih_fifo, ih_ring_entry, count = kfifo_out(&node->ih_fifo, ih_ring_entry,
kfd->device_info.ih_ring_entry_size); node->kfd->device_info.ih_ring_entry_size);
WARN_ON(count && count != kfd->device_info.ih_ring_entry_size); WARN_ON(count && count != node->kfd->device_info.ih_ring_entry_size);
return count == kfd->device_info.ih_ring_entry_size; return count == node->kfd->device_info.ih_ring_entry_size;
} }
static void interrupt_wq(struct work_struct *work) static void interrupt_wq(struct work_struct *work)
{ {
struct kfd_dev *dev = container_of(work, struct kfd_dev, struct kfd_node *dev = container_of(work, struct kfd_node,
interrupt_work); interrupt_work);
uint32_t ih_ring_entry[KFD_MAX_RING_ENTRY_SIZE]; uint32_t ih_ring_entry[KFD_MAX_RING_ENTRY_SIZE];
unsigned long start_jiffies = jiffies; unsigned long start_jiffies = jiffies;
if (dev->device_info.ih_ring_entry_size > sizeof(ih_ring_entry)) { if (dev->kfd->device_info.ih_ring_entry_size > sizeof(ih_ring_entry)) {
dev_err_once(dev->adev->dev, "Ring entry too small\n"); dev_err_once(dev->adev->dev, "Ring entry too small\n");
return; return;
} }
while (dequeue_ih_ring_entry(dev, ih_ring_entry)) { while (dequeue_ih_ring_entry(dev, ih_ring_entry)) {
dev->device_info.event_interrupt_class->interrupt_wq(dev, dev->kfd->device_info.event_interrupt_class->interrupt_wq(dev,
ih_ring_entry); ih_ring_entry);
if (time_is_before_jiffies(start_jiffies + HZ)) { if (time_is_before_jiffies(start_jiffies + HZ)) {
/* If we spent more than a second processing signals, /* If we spent more than a second processing signals,
...@@ -166,14 +166,14 @@ static void interrupt_wq(struct work_struct *work) ...@@ -166,14 +166,14 @@ static void interrupt_wq(struct work_struct *work)
} }
} }
bool interrupt_is_wanted(struct kfd_dev *dev, bool interrupt_is_wanted(struct kfd_node *dev,
const uint32_t *ih_ring_entry, const uint32_t *ih_ring_entry,
uint32_t *patched_ihre, bool *flag) uint32_t *patched_ihre, bool *flag)
{ {
/* integer and bitwise OR so there is no boolean short-circuiting */ /* integer and bitwise OR so there is no boolean short-circuiting */
unsigned int wanted = 0; unsigned int wanted = 0;
wanted |= dev->device_info.event_interrupt_class->interrupt_isr(dev, wanted |= dev->kfd->device_info.event_interrupt_class->interrupt_isr(dev,
ih_ring_entry, patched_ihre, flag); ih_ring_entry, patched_ihre, flag);
return wanted != 0; return wanted != 0;
......
...@@ -109,11 +109,11 @@ int kfd_iommu_device_init(struct kfd_dev *kfd) ...@@ -109,11 +109,11 @@ int kfd_iommu_device_init(struct kfd_dev *kfd)
*/ */
int kfd_iommu_bind_process_to_device(struct kfd_process_device *pdd) int kfd_iommu_bind_process_to_device(struct kfd_process_device *pdd)
{ {
struct kfd_dev *dev = pdd->dev; struct kfd_node *dev = pdd->dev;
struct kfd_process *p = pdd->process; struct kfd_process *p = pdd->process;
int err; int err;
if (!dev->use_iommu_v2 || pdd->bound == PDD_BOUND) if (!dev->kfd->use_iommu_v2 || pdd->bound == PDD_BOUND)
return 0; return 0;
if (unlikely(pdd->bound == PDD_BOUND_SUSPENDED)) { if (unlikely(pdd->bound == PDD_BOUND_SUSPENDED)) {
...@@ -146,7 +146,7 @@ void kfd_iommu_unbind_process(struct kfd_process *p) ...@@ -146,7 +146,7 @@ void kfd_iommu_unbind_process(struct kfd_process *p)
/* Callback for process shutdown invoked by the IOMMU driver */ /* Callback for process shutdown invoked by the IOMMU driver */
static void iommu_pasid_shutdown_callback(struct pci_dev *pdev, u32 pasid) static void iommu_pasid_shutdown_callback(struct pci_dev *pdev, u32 pasid)
{ {
struct kfd_dev *dev = kfd_device_by_pci_dev(pdev); struct kfd_node *dev = kfd_device_by_pci_dev(pdev);
struct kfd_process *p; struct kfd_process *p;
struct kfd_process_device *pdd; struct kfd_process_device *pdd;
...@@ -182,7 +182,7 @@ static void iommu_pasid_shutdown_callback(struct pci_dev *pdev, u32 pasid) ...@@ -182,7 +182,7 @@ static void iommu_pasid_shutdown_callback(struct pci_dev *pdev, u32 pasid)
static int iommu_invalid_ppr_cb(struct pci_dev *pdev, u32 pasid, static int iommu_invalid_ppr_cb(struct pci_dev *pdev, u32 pasid,
unsigned long address, u16 flags) unsigned long address, u16 flags)
{ {
struct kfd_dev *dev; struct kfd_node *dev;
dev_warn_ratelimited(kfd_device, dev_warn_ratelimited(kfd_device,
"Invalid PPR device %x:%x.%x pasid 0x%x address 0x%lX flags 0x%X", "Invalid PPR device %x:%x.%x pasid 0x%x address 0x%lX flags 0x%X",
...@@ -205,7 +205,7 @@ static int iommu_invalid_ppr_cb(struct pci_dev *pdev, u32 pasid, ...@@ -205,7 +205,7 @@ static int iommu_invalid_ppr_cb(struct pci_dev *pdev, u32 pasid,
* Bind processes do the device that have been temporarily unbound * Bind processes do the device that have been temporarily unbound
* (PDD_BOUND_SUSPENDED) in kfd_unbind_processes_from_device. * (PDD_BOUND_SUSPENDED) in kfd_unbind_processes_from_device.
*/ */
static int kfd_bind_processes_to_device(struct kfd_dev *kfd) static int kfd_bind_processes_to_device(struct kfd_node *knode)
{ {
struct kfd_process_device *pdd; struct kfd_process_device *pdd;
struct kfd_process *p; struct kfd_process *p;
...@@ -216,14 +216,14 @@ static int kfd_bind_processes_to_device(struct kfd_dev *kfd) ...@@ -216,14 +216,14 @@ static int kfd_bind_processes_to_device(struct kfd_dev *kfd)
hash_for_each_rcu(kfd_processes_table, temp, p, kfd_processes) { hash_for_each_rcu(kfd_processes_table, temp, p, kfd_processes) {
mutex_lock(&p->mutex); mutex_lock(&p->mutex);
pdd = kfd_get_process_device_data(kfd, p); pdd = kfd_get_process_device_data(knode, p);
if (WARN_ON(!pdd) || pdd->bound != PDD_BOUND_SUSPENDED) { if (WARN_ON(!pdd) || pdd->bound != PDD_BOUND_SUSPENDED) {
mutex_unlock(&p->mutex); mutex_unlock(&p->mutex);
continue; continue;
} }
err = amd_iommu_bind_pasid(kfd->adev->pdev, p->pasid, err = amd_iommu_bind_pasid(knode->adev->pdev, p->pasid,
p->lead_thread); p->lead_thread);
if (err < 0) { if (err < 0) {
pr_err("Unexpected pasid 0x%x binding failure\n", pr_err("Unexpected pasid 0x%x binding failure\n",
...@@ -246,7 +246,7 @@ static int kfd_bind_processes_to_device(struct kfd_dev *kfd) ...@@ -246,7 +246,7 @@ static int kfd_bind_processes_to_device(struct kfd_dev *kfd)
* processes will be restored to PDD_BOUND state in * processes will be restored to PDD_BOUND state in
* kfd_bind_processes_to_device. * kfd_bind_processes_to_device.
*/ */
static void kfd_unbind_processes_from_device(struct kfd_dev *kfd) static void kfd_unbind_processes_from_device(struct kfd_node *knode)
{ {
struct kfd_process_device *pdd; struct kfd_process_device *pdd;
struct kfd_process *p; struct kfd_process *p;
...@@ -256,7 +256,7 @@ static void kfd_unbind_processes_from_device(struct kfd_dev *kfd) ...@@ -256,7 +256,7 @@ static void kfd_unbind_processes_from_device(struct kfd_dev *kfd)
hash_for_each_rcu(kfd_processes_table, temp, p, kfd_processes) { hash_for_each_rcu(kfd_processes_table, temp, p, kfd_processes) {
mutex_lock(&p->mutex); mutex_lock(&p->mutex);
pdd = kfd_get_process_device_data(kfd, p); pdd = kfd_get_process_device_data(knode, p);
if (WARN_ON(!pdd)) { if (WARN_ON(!pdd)) {
mutex_unlock(&p->mutex); mutex_unlock(&p->mutex);
...@@ -281,7 +281,7 @@ void kfd_iommu_suspend(struct kfd_dev *kfd) ...@@ -281,7 +281,7 @@ void kfd_iommu_suspend(struct kfd_dev *kfd)
if (!kfd->use_iommu_v2) if (!kfd->use_iommu_v2)
return; return;
kfd_unbind_processes_from_device(kfd); kfd_unbind_processes_from_device(kfd->node);
amd_iommu_set_invalidate_ctx_cb(kfd->adev->pdev, NULL); amd_iommu_set_invalidate_ctx_cb(kfd->adev->pdev, NULL);
amd_iommu_set_invalid_ppr_cb(kfd->adev->pdev, NULL); amd_iommu_set_invalid_ppr_cb(kfd->adev->pdev, NULL);
...@@ -312,7 +312,7 @@ int kfd_iommu_resume(struct kfd_dev *kfd) ...@@ -312,7 +312,7 @@ int kfd_iommu_resume(struct kfd_dev *kfd)
amd_iommu_set_invalid_ppr_cb(kfd->adev->pdev, amd_iommu_set_invalid_ppr_cb(kfd->adev->pdev,
iommu_invalid_ppr_cb); iommu_invalid_ppr_cb);
err = kfd_bind_processes_to_device(kfd); err = kfd_bind_processes_to_device(kfd->node);
if (err) { if (err) {
amd_iommu_set_invalidate_ctx_cb(kfd->adev->pdev, NULL); amd_iommu_set_invalidate_ctx_cb(kfd->adev->pdev, NULL);
amd_iommu_set_invalid_ppr_cb(kfd->adev->pdev, NULL); amd_iommu_set_invalid_ppr_cb(kfd->adev->pdev, NULL);
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
/* Initialize a kernel queue, including allocations of GART memory /* Initialize a kernel queue, including allocations of GART memory
* needed for the queue. * needed for the queue.
*/ */
static bool kq_initialize(struct kernel_queue *kq, struct kfd_dev *dev, static bool kq_initialize(struct kernel_queue *kq, struct kfd_node *dev,
enum kfd_queue_type type, unsigned int queue_size) enum kfd_queue_type type, unsigned int queue_size)
{ {
struct queue_properties prop; struct queue_properties prop;
...@@ -75,7 +75,7 @@ static bool kq_initialize(struct kernel_queue *kq, struct kfd_dev *dev, ...@@ -75,7 +75,7 @@ static bool kq_initialize(struct kernel_queue *kq, struct kfd_dev *dev,
if (!kq->mqd_mgr) if (!kq->mqd_mgr)
return false; return false;
prop.doorbell_ptr = kfd_get_kernel_doorbell(dev, &prop.doorbell_off); prop.doorbell_ptr = kfd_get_kernel_doorbell(dev->kfd, &prop.doorbell_off);
if (!prop.doorbell_ptr) { if (!prop.doorbell_ptr) {
pr_err("Failed to initialize doorbell"); pr_err("Failed to initialize doorbell");
...@@ -112,7 +112,7 @@ static bool kq_initialize(struct kernel_queue *kq, struct kfd_dev *dev, ...@@ -112,7 +112,7 @@ static bool kq_initialize(struct kernel_queue *kq, struct kfd_dev *dev,
kq->rptr_kernel = kq->rptr_mem->cpu_ptr; kq->rptr_kernel = kq->rptr_mem->cpu_ptr;
kq->rptr_gpu_addr = kq->rptr_mem->gpu_addr; kq->rptr_gpu_addr = kq->rptr_mem->gpu_addr;
retval = kfd_gtt_sa_allocate(dev, dev->device_info.doorbell_size, retval = kfd_gtt_sa_allocate(dev, dev->kfd->device_info.doorbell_size,
&kq->wptr_mem); &kq->wptr_mem);
if (retval != 0) if (retval != 0)
...@@ -189,7 +189,7 @@ static bool kq_initialize(struct kernel_queue *kq, struct kfd_dev *dev, ...@@ -189,7 +189,7 @@ static bool kq_initialize(struct kernel_queue *kq, struct kfd_dev *dev,
err_eop_allocate_vidmem: err_eop_allocate_vidmem:
kfd_gtt_sa_free(dev, kq->pq); kfd_gtt_sa_free(dev, kq->pq);
err_pq_allocate_vidmem: err_pq_allocate_vidmem:
kfd_release_kernel_doorbell(dev, prop.doorbell_ptr); kfd_release_kernel_doorbell(dev->kfd, prop.doorbell_ptr);
err_get_kernel_doorbell: err_get_kernel_doorbell:
return false; return false;
...@@ -220,7 +220,7 @@ static void kq_uninitialize(struct kernel_queue *kq, bool hanging) ...@@ -220,7 +220,7 @@ static void kq_uninitialize(struct kernel_queue *kq, bool hanging)
kfd_gtt_sa_free(kq->dev, kq->eop_mem); kfd_gtt_sa_free(kq->dev, kq->eop_mem);
kfd_gtt_sa_free(kq->dev, kq->pq); kfd_gtt_sa_free(kq->dev, kq->pq);
kfd_release_kernel_doorbell(kq->dev, kfd_release_kernel_doorbell(kq->dev->kfd,
kq->queue->properties.doorbell_ptr); kq->queue->properties.doorbell_ptr);
uninit_queue(kq->queue); uninit_queue(kq->queue);
} }
...@@ -298,7 +298,7 @@ void kq_submit_packet(struct kernel_queue *kq) ...@@ -298,7 +298,7 @@ void kq_submit_packet(struct kernel_queue *kq)
} }
pr_debug("\n"); pr_debug("\n");
#endif #endif
if (kq->dev->device_info.doorbell_size == 8) { if (kq->dev->kfd->device_info.doorbell_size == 8) {
*kq->wptr64_kernel = kq->pending_wptr64; *kq->wptr64_kernel = kq->pending_wptr64;
write_kernel_doorbell64(kq->queue->properties.doorbell_ptr, write_kernel_doorbell64(kq->queue->properties.doorbell_ptr,
kq->pending_wptr64); kq->pending_wptr64);
...@@ -311,7 +311,7 @@ void kq_submit_packet(struct kernel_queue *kq) ...@@ -311,7 +311,7 @@ void kq_submit_packet(struct kernel_queue *kq)
void kq_rollback_packet(struct kernel_queue *kq) void kq_rollback_packet(struct kernel_queue *kq)
{ {
if (kq->dev->device_info.doorbell_size == 8) { if (kq->dev->kfd->device_info.doorbell_size == 8) {
kq->pending_wptr64 = *kq->wptr64_kernel; kq->pending_wptr64 = *kq->wptr64_kernel;
kq->pending_wptr = *kq->wptr_kernel % kq->pending_wptr = *kq->wptr_kernel %
(kq->queue->properties.queue_size / 4); (kq->queue->properties.queue_size / 4);
...@@ -320,7 +320,7 @@ void kq_rollback_packet(struct kernel_queue *kq) ...@@ -320,7 +320,7 @@ void kq_rollback_packet(struct kernel_queue *kq)
} }
} }
struct kernel_queue *kernel_queue_init(struct kfd_dev *dev, struct kernel_queue *kernel_queue_init(struct kfd_node *dev,
enum kfd_queue_type type) enum kfd_queue_type type)
{ {
struct kernel_queue *kq; struct kernel_queue *kq;
...@@ -345,7 +345,7 @@ void kernel_queue_uninit(struct kernel_queue *kq, bool hanging) ...@@ -345,7 +345,7 @@ void kernel_queue_uninit(struct kernel_queue *kq, bool hanging)
} }
/* FIXME: Can this test be removed? */ /* FIXME: Can this test be removed? */
static __attribute__((unused)) void test_kq(struct kfd_dev *dev) static __attribute__((unused)) void test_kq(struct kfd_node *dev)
{ {
struct kernel_queue *kq; struct kernel_queue *kq;
uint32_t *buffer, i; uint32_t *buffer, i;
......
...@@ -53,7 +53,7 @@ void kq_rollback_packet(struct kernel_queue *kq); ...@@ -53,7 +53,7 @@ void kq_rollback_packet(struct kernel_queue *kq);
struct kernel_queue { struct kernel_queue {
/* data */ /* data */
struct kfd_dev *dev; struct kfd_node *dev;
struct mqd_manager *mqd_mgr; struct mqd_manager *mqd_mgr;
struct queue *queue; struct queue *queue;
uint64_t pending_wptr64; uint64_t pending_wptr64;
......
...@@ -423,7 +423,7 @@ svm_migrate_vma_to_vram(struct amdgpu_device *adev, struct svm_range *prange, ...@@ -423,7 +423,7 @@ svm_migrate_vma_to_vram(struct amdgpu_device *adev, struct svm_range *prange,
kfd_smi_event_migration_start(adev->kfd.dev, p->lead_thread->pid, kfd_smi_event_migration_start(adev->kfd.dev, p->lead_thread->pid,
start >> PAGE_SHIFT, end >> PAGE_SHIFT, start >> PAGE_SHIFT, end >> PAGE_SHIFT,
0, adev->kfd.dev->id, prange->prefetch_loc, 0, adev->kfd.dev->node->id, prange->prefetch_loc,
prange->preferred_loc, trigger); prange->preferred_loc, trigger);
r = migrate_vma_setup(&migrate); r = migrate_vma_setup(&migrate);
...@@ -456,7 +456,7 @@ svm_migrate_vma_to_vram(struct amdgpu_device *adev, struct svm_range *prange, ...@@ -456,7 +456,7 @@ svm_migrate_vma_to_vram(struct amdgpu_device *adev, struct svm_range *prange,
kfd_smi_event_migration_end(adev->kfd.dev, p->lead_thread->pid, kfd_smi_event_migration_end(adev->kfd.dev, p->lead_thread->pid,
start >> PAGE_SHIFT, end >> PAGE_SHIFT, start >> PAGE_SHIFT, end >> PAGE_SHIFT,
0, adev->kfd.dev->id, trigger); 0, adev->kfd.dev->node->id, trigger);
svm_range_dma_unmap(adev->dev, scratch, 0, npages); svm_range_dma_unmap(adev->dev, scratch, 0, npages);
svm_range_free_dma_mappings(prange); svm_range_free_dma_mappings(prange);
...@@ -701,7 +701,7 @@ svm_migrate_vma_to_ram(struct amdgpu_device *adev, struct svm_range *prange, ...@@ -701,7 +701,7 @@ svm_migrate_vma_to_ram(struct amdgpu_device *adev, struct svm_range *prange,
kfd_smi_event_migration_start(adev->kfd.dev, p->lead_thread->pid, kfd_smi_event_migration_start(adev->kfd.dev, p->lead_thread->pid,
start >> PAGE_SHIFT, end >> PAGE_SHIFT, start >> PAGE_SHIFT, end >> PAGE_SHIFT,
adev->kfd.dev->id, 0, prange->prefetch_loc, adev->kfd.dev->node->id, 0, prange->prefetch_loc,
prange->preferred_loc, trigger); prange->preferred_loc, trigger);
r = migrate_vma_setup(&migrate); r = migrate_vma_setup(&migrate);
...@@ -737,7 +737,7 @@ svm_migrate_vma_to_ram(struct amdgpu_device *adev, struct svm_range *prange, ...@@ -737,7 +737,7 @@ svm_migrate_vma_to_ram(struct amdgpu_device *adev, struct svm_range *prange,
kfd_smi_event_migration_end(adev->kfd.dev, p->lead_thread->pid, kfd_smi_event_migration_end(adev->kfd.dev, p->lead_thread->pid,
start >> PAGE_SHIFT, end >> PAGE_SHIFT, start >> PAGE_SHIFT, end >> PAGE_SHIFT,
adev->kfd.dev->id, 0, trigger); adev->kfd.dev->node->id, 0, trigger);
svm_range_dma_unmap(adev->dev, scratch, 0, npages); svm_range_dma_unmap(adev->dev, scratch, 0, npages);
......
...@@ -46,7 +46,7 @@ int pipe_priority_map[] = { ...@@ -46,7 +46,7 @@ int pipe_priority_map[] = {
KFD_PIPE_PRIORITY_CS_HIGH KFD_PIPE_PRIORITY_CS_HIGH
}; };
struct kfd_mem_obj *allocate_hiq_mqd(struct kfd_dev *dev, struct queue_properties *q) struct kfd_mem_obj *allocate_hiq_mqd(struct kfd_node *dev, struct queue_properties *q)
{ {
struct kfd_mem_obj *mqd_mem_obj = NULL; struct kfd_mem_obj *mqd_mem_obj = NULL;
...@@ -61,7 +61,7 @@ struct kfd_mem_obj *allocate_hiq_mqd(struct kfd_dev *dev, struct queue_propertie ...@@ -61,7 +61,7 @@ struct kfd_mem_obj *allocate_hiq_mqd(struct kfd_dev *dev, struct queue_propertie
return mqd_mem_obj; return mqd_mem_obj;
} }
struct kfd_mem_obj *allocate_sdma_mqd(struct kfd_dev *dev, struct kfd_mem_obj *allocate_sdma_mqd(struct kfd_node *dev,
struct queue_properties *q) struct queue_properties *q)
{ {
struct kfd_mem_obj *mqd_mem_obj = NULL; struct kfd_mem_obj *mqd_mem_obj = NULL;
...@@ -72,7 +72,7 @@ struct kfd_mem_obj *allocate_sdma_mqd(struct kfd_dev *dev, ...@@ -72,7 +72,7 @@ struct kfd_mem_obj *allocate_sdma_mqd(struct kfd_dev *dev,
return NULL; return NULL;
offset = (q->sdma_engine_id * offset = (q->sdma_engine_id *
dev->device_info.num_sdma_queues_per_engine + dev->kfd->device_info.num_sdma_queues_per_engine +
q->sdma_queue_id) * q->sdma_queue_id) *
dev->dqm->mqd_mgrs[KFD_MQD_TYPE_SDMA]->mqd_size; dev->dqm->mqd_mgrs[KFD_MQD_TYPE_SDMA]->mqd_size;
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
*/ */
extern int pipe_priority_map[]; extern int pipe_priority_map[];
struct mqd_manager { struct mqd_manager {
struct kfd_mem_obj* (*allocate_mqd)(struct kfd_dev *kfd, struct kfd_mem_obj* (*allocate_mqd)(struct kfd_node *kfd,
struct queue_properties *q); struct queue_properties *q);
void (*init_mqd)(struct mqd_manager *mm, void **mqd, void (*init_mqd)(struct mqd_manager *mm, void **mqd,
...@@ -121,14 +121,14 @@ struct mqd_manager { ...@@ -121,14 +121,14 @@ struct mqd_manager {
uint32_t (*read_doorbell_id)(void *mqd); uint32_t (*read_doorbell_id)(void *mqd);
struct mutex mqd_mutex; struct mutex mqd_mutex;
struct kfd_dev *dev; struct kfd_node *dev;
uint32_t mqd_size; uint32_t mqd_size;
}; };
struct kfd_mem_obj *allocate_hiq_mqd(struct kfd_dev *dev, struct kfd_mem_obj *allocate_hiq_mqd(struct kfd_node *dev,
struct queue_properties *q); struct queue_properties *q);
struct kfd_mem_obj *allocate_sdma_mqd(struct kfd_dev *dev, struct kfd_mem_obj *allocate_sdma_mqd(struct kfd_node *dev,
struct queue_properties *q); struct queue_properties *q);
void free_mqd_hiq_sdma(struct mqd_manager *mm, void *mqd, void free_mqd_hiq_sdma(struct mqd_manager *mm, void *mqd,
struct kfd_mem_obj *mqd_mem_obj); struct kfd_mem_obj *mqd_mem_obj);
......
...@@ -74,7 +74,7 @@ static void set_priority(struct cik_mqd *m, struct queue_properties *q) ...@@ -74,7 +74,7 @@ static void set_priority(struct cik_mqd *m, struct queue_properties *q)
m->cp_hqd_queue_priority = q->priority; m->cp_hqd_queue_priority = q->priority;
} }
static struct kfd_mem_obj *allocate_mqd(struct kfd_dev *kfd, static struct kfd_mem_obj *allocate_mqd(struct kfd_node *kfd,
struct queue_properties *q) struct queue_properties *q)
{ {
struct kfd_mem_obj *mqd_mem_obj; struct kfd_mem_obj *mqd_mem_obj;
...@@ -390,7 +390,7 @@ static int debugfs_show_mqd_sdma(struct seq_file *m, void *data) ...@@ -390,7 +390,7 @@ static int debugfs_show_mqd_sdma(struct seq_file *m, void *data)
struct mqd_manager *mqd_manager_init_cik(enum KFD_MQD_TYPE type, struct mqd_manager *mqd_manager_init_cik(enum KFD_MQD_TYPE type,
struct kfd_dev *dev) struct kfd_node *dev)
{ {
struct mqd_manager *mqd; struct mqd_manager *mqd;
...@@ -470,7 +470,7 @@ struct mqd_manager *mqd_manager_init_cik(enum KFD_MQD_TYPE type, ...@@ -470,7 +470,7 @@ struct mqd_manager *mqd_manager_init_cik(enum KFD_MQD_TYPE type,
} }
struct mqd_manager *mqd_manager_init_cik_hawaii(enum KFD_MQD_TYPE type, struct mqd_manager *mqd_manager_init_cik_hawaii(enum KFD_MQD_TYPE type,
struct kfd_dev *dev) struct kfd_node *dev)
{ {
struct mqd_manager *mqd; struct mqd_manager *mqd;
......
...@@ -74,7 +74,7 @@ static void set_priority(struct v10_compute_mqd *m, struct queue_properties *q) ...@@ -74,7 +74,7 @@ static void set_priority(struct v10_compute_mqd *m, struct queue_properties *q)
m->cp_hqd_queue_priority = q->priority; m->cp_hqd_queue_priority = q->priority;
} }
static struct kfd_mem_obj *allocate_mqd(struct kfd_dev *kfd, static struct kfd_mem_obj *allocate_mqd(struct kfd_node *kfd,
struct queue_properties *q) struct queue_properties *q)
{ {
struct kfd_mem_obj *mqd_mem_obj; struct kfd_mem_obj *mqd_mem_obj;
...@@ -122,7 +122,7 @@ static void init_mqd(struct mqd_manager *mm, void **mqd, ...@@ -122,7 +122,7 @@ static void init_mqd(struct mqd_manager *mm, void **mqd,
1 << CP_HQD_AQL_CONTROL__CONTROL0__SHIFT; 1 << CP_HQD_AQL_CONTROL__CONTROL0__SHIFT;
} }
if (mm->dev->cwsr_enabled) { if (mm->dev->kfd->cwsr_enabled) {
m->cp_hqd_persistent_state |= m->cp_hqd_persistent_state |=
(1 << CP_HQD_PERSISTENT_STATE__QSWITCH_MODE__SHIFT); (1 << CP_HQD_PERSISTENT_STATE__QSWITCH_MODE__SHIFT);
m->cp_hqd_ctx_save_base_addr_lo = m->cp_hqd_ctx_save_base_addr_lo =
...@@ -210,7 +210,7 @@ static void update_mqd(struct mqd_manager *mm, void *mqd, ...@@ -210,7 +210,7 @@ static void update_mqd(struct mqd_manager *mm, void *mqd,
m->cp_hqd_pq_doorbell_control |= m->cp_hqd_pq_doorbell_control |=
1 << CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_BIF_DROP__SHIFT; 1 << CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_BIF_DROP__SHIFT;
} }
if (mm->dev->cwsr_enabled) if (mm->dev->kfd->cwsr_enabled)
m->cp_hqd_ctx_save_control = 0; m->cp_hqd_ctx_save_control = 0;
update_cu_mask(mm, mqd, minfo); update_cu_mask(mm, mqd, minfo);
...@@ -405,7 +405,7 @@ static int debugfs_show_mqd_sdma(struct seq_file *m, void *data) ...@@ -405,7 +405,7 @@ static int debugfs_show_mqd_sdma(struct seq_file *m, void *data)
#endif #endif
struct mqd_manager *mqd_manager_init_v10(enum KFD_MQD_TYPE type, struct mqd_manager *mqd_manager_init_v10(enum KFD_MQD_TYPE type,
struct kfd_dev *dev) struct kfd_node *dev)
{ {
struct mqd_manager *mqd; struct mqd_manager *mqd;
......
...@@ -81,7 +81,7 @@ static void set_priority(struct v11_compute_mqd *m, struct queue_properties *q) ...@@ -81,7 +81,7 @@ static void set_priority(struct v11_compute_mqd *m, struct queue_properties *q)
m->cp_hqd_queue_priority = q->priority; m->cp_hqd_queue_priority = q->priority;
} }
static struct kfd_mem_obj *allocate_mqd(struct kfd_dev *kfd, static struct kfd_mem_obj *allocate_mqd(struct kfd_node *node,
struct queue_properties *q) struct queue_properties *q)
{ {
struct kfd_mem_obj *mqd_mem_obj; struct kfd_mem_obj *mqd_mem_obj;
...@@ -91,12 +91,12 @@ static struct kfd_mem_obj *allocate_mqd(struct kfd_dev *kfd, ...@@ -91,12 +91,12 @@ static struct kfd_mem_obj *allocate_mqd(struct kfd_dev *kfd,
* MES write to areas beyond MQD size. So allocate * MES write to areas beyond MQD size. So allocate
* 1 PAGE_SIZE memory for MQD is MES is enabled. * 1 PAGE_SIZE memory for MQD is MES is enabled.
*/ */
if (kfd->shared_resources.enable_mes) if (node->kfd->shared_resources.enable_mes)
size = PAGE_SIZE; size = PAGE_SIZE;
else else
size = sizeof(struct v11_compute_mqd); size = sizeof(struct v11_compute_mqd);
if (kfd_gtt_sa_allocate(kfd, size, &mqd_mem_obj)) if (kfd_gtt_sa_allocate(node, size, &mqd_mem_obj))
return NULL; return NULL;
return mqd_mem_obj; return mqd_mem_obj;
...@@ -113,7 +113,7 @@ static void init_mqd(struct mqd_manager *mm, void **mqd, ...@@ -113,7 +113,7 @@ static void init_mqd(struct mqd_manager *mm, void **mqd,
m = (struct v11_compute_mqd *) mqd_mem_obj->cpu_ptr; m = (struct v11_compute_mqd *) mqd_mem_obj->cpu_ptr;
addr = mqd_mem_obj->gpu_addr; addr = mqd_mem_obj->gpu_addr;
if (mm->dev->shared_resources.enable_mes) if (mm->dev->kfd->shared_resources.enable_mes)
size = PAGE_SIZE; size = PAGE_SIZE;
else else
size = sizeof(struct v11_compute_mqd); size = sizeof(struct v11_compute_mqd);
...@@ -155,7 +155,7 @@ static void init_mqd(struct mqd_manager *mm, void **mqd, ...@@ -155,7 +155,7 @@ static void init_mqd(struct mqd_manager *mm, void **mqd,
1 << CP_HQD_AQL_CONTROL__CONTROL0__SHIFT; 1 << CP_HQD_AQL_CONTROL__CONTROL0__SHIFT;
} }
if (mm->dev->cwsr_enabled) { if (mm->dev->kfd->cwsr_enabled) {
m->cp_hqd_persistent_state |= m->cp_hqd_persistent_state |=
(1 << CP_HQD_PERSISTENT_STATE__QSWITCH_MODE__SHIFT); (1 << CP_HQD_PERSISTENT_STATE__QSWITCH_MODE__SHIFT);
m->cp_hqd_ctx_save_base_addr_lo = m->cp_hqd_ctx_save_base_addr_lo =
...@@ -243,7 +243,7 @@ static void update_mqd(struct mqd_manager *mm, void *mqd, ...@@ -243,7 +243,7 @@ static void update_mqd(struct mqd_manager *mm, void *mqd,
m->cp_hqd_pq_doorbell_control |= m->cp_hqd_pq_doorbell_control |=
1 << CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_BIF_DROP__SHIFT; 1 << CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_BIF_DROP__SHIFT;
} }
if (mm->dev->cwsr_enabled) if (mm->dev->kfd->cwsr_enabled)
m->cp_hqd_ctx_save_control = 0; m->cp_hqd_ctx_save_control = 0;
update_cu_mask(mm, mqd, minfo); update_cu_mask(mm, mqd, minfo);
...@@ -319,7 +319,7 @@ static void init_mqd_sdma(struct mqd_manager *mm, void **mqd, ...@@ -319,7 +319,7 @@ static void init_mqd_sdma(struct mqd_manager *mm, void **mqd,
m = (struct v11_sdma_mqd *) mqd_mem_obj->cpu_ptr; m = (struct v11_sdma_mqd *) mqd_mem_obj->cpu_ptr;
if (mm->dev->shared_resources.enable_mes) if (mm->dev->kfd->shared_resources.enable_mes)
size = PAGE_SIZE; size = PAGE_SIZE;
else else
size = sizeof(struct v11_sdma_mqd); size = sizeof(struct v11_sdma_mqd);
...@@ -387,7 +387,7 @@ static int debugfs_show_mqd_sdma(struct seq_file *m, void *data) ...@@ -387,7 +387,7 @@ static int debugfs_show_mqd_sdma(struct seq_file *m, void *data)
#endif #endif
struct mqd_manager *mqd_manager_init_v11(enum KFD_MQD_TYPE type, struct mqd_manager *mqd_manager_init_v11(enum KFD_MQD_TYPE type,
struct kfd_dev *dev) struct kfd_node *dev)
{ {
struct mqd_manager *mqd; struct mqd_manager *mqd;
...@@ -463,7 +463,7 @@ struct mqd_manager *mqd_manager_init_v11(enum KFD_MQD_TYPE type, ...@@ -463,7 +463,7 @@ struct mqd_manager *mqd_manager_init_v11(enum KFD_MQD_TYPE type,
* To allocate SDMA MQDs by generic functions * To allocate SDMA MQDs by generic functions
* when MES is enabled. * when MES is enabled.
*/ */
if (dev->shared_resources.enable_mes) { if (dev->kfd->shared_resources.enable_mes) {
mqd->allocate_mqd = allocate_mqd; mqd->allocate_mqd = allocate_mqd;
mqd->free_mqd = kfd_free_mqd_cp; mqd->free_mqd = kfd_free_mqd_cp;
} }
......
...@@ -83,7 +83,7 @@ static void set_priority(struct v9_mqd *m, struct queue_properties *q) ...@@ -83,7 +83,7 @@ static void set_priority(struct v9_mqd *m, struct queue_properties *q)
m->cp_hqd_queue_priority = q->priority; m->cp_hqd_queue_priority = q->priority;
} }
static struct kfd_mem_obj *allocate_mqd(struct kfd_dev *kfd, static struct kfd_mem_obj *allocate_mqd(struct kfd_node *node,
struct queue_properties *q) struct queue_properties *q)
{ {
int retval; int retval;
...@@ -105,11 +105,11 @@ static struct kfd_mem_obj *allocate_mqd(struct kfd_dev *kfd, ...@@ -105,11 +105,11 @@ static struct kfd_mem_obj *allocate_mqd(struct kfd_dev *kfd,
* pass a special bo flag AMDGPU_GEM_CREATE_CP_MQD_GFX9 to instruct * pass a special bo flag AMDGPU_GEM_CREATE_CP_MQD_GFX9 to instruct
* amdgpu memory functions to do so. * amdgpu memory functions to do so.
*/ */
if (kfd->cwsr_enabled && (q->type == KFD_QUEUE_TYPE_COMPUTE)) { if (node->kfd->cwsr_enabled && (q->type == KFD_QUEUE_TYPE_COMPUTE)) {
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 NULL; return NULL;
retval = amdgpu_amdkfd_alloc_gtt_mem(kfd->adev, retval = amdgpu_amdkfd_alloc_gtt_mem(node->adev,
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),
...@@ -121,7 +121,7 @@ static struct kfd_mem_obj *allocate_mqd(struct kfd_dev *kfd, ...@@ -121,7 +121,7 @@ static struct kfd_mem_obj *allocate_mqd(struct kfd_dev *kfd,
return NULL; return NULL;
} }
} else { } else {
retval = kfd_gtt_sa_allocate(kfd, sizeof(struct v9_mqd), retval = kfd_gtt_sa_allocate(node, sizeof(struct v9_mqd),
&mqd_mem_obj); &mqd_mem_obj);
if (retval) if (retval)
return NULL; return NULL;
...@@ -136,7 +136,6 @@ static void init_mqd(struct mqd_manager *mm, void **mqd, ...@@ -136,7 +136,6 @@ static void init_mqd(struct mqd_manager *mm, void **mqd,
{ {
uint64_t addr; uint64_t addr;
struct v9_mqd *m; struct v9_mqd *m;
struct amdgpu_device *adev = (struct amdgpu_device *)mm->dev->adev;
m = (struct v9_mqd *) mqd_mem_obj->cpu_ptr; m = (struct v9_mqd *) mqd_mem_obj->cpu_ptr;
addr = mqd_mem_obj->gpu_addr; addr = mqd_mem_obj->gpu_addr;
...@@ -169,7 +168,7 @@ static void init_mqd(struct mqd_manager *mm, void **mqd, ...@@ -169,7 +168,7 @@ static void init_mqd(struct mqd_manager *mm, void **mqd,
if (q->format == KFD_QUEUE_FORMAT_AQL) { if (q->format == KFD_QUEUE_FORMAT_AQL) {
m->cp_hqd_aql_control = m->cp_hqd_aql_control =
1 << CP_HQD_AQL_CONTROL__CONTROL0__SHIFT; 1 << CP_HQD_AQL_CONTROL__CONTROL0__SHIFT;
if (adev->ip_versions[GC_HWIP][0] == IP_VERSION(9, 4, 3)) { if (KFD_GC_VERSION(mm->dev) == IP_VERSION(9, 4, 3)) {
/* On GC 9.4.3, DW 41 is re-purposed as /* On GC 9.4.3, DW 41 is re-purposed as
* compute_tg_chunk_size. * compute_tg_chunk_size.
* TODO: review this setting when active CUs in the * TODO: review this setting when active CUs in the
...@@ -179,7 +178,7 @@ static void init_mqd(struct mqd_manager *mm, void **mqd, ...@@ -179,7 +178,7 @@ static void init_mqd(struct mqd_manager *mm, void **mqd,
} }
} else { } else {
/* PM4 queue */ /* PM4 queue */
if (adev->ip_versions[GC_HWIP][0] == IP_VERSION(9, 4, 3)) { if (KFD_GC_VERSION(mm->dev) == IP_VERSION(9, 4, 3)) {
m->compute_static_thread_mgmt_se6 = 0; m->compute_static_thread_mgmt_se6 = 0;
/* TODO: program pm4_target_xcc */ /* TODO: program pm4_target_xcc */
} }
...@@ -190,7 +189,7 @@ static void init_mqd(struct mqd_manager *mm, void **mqd, ...@@ -190,7 +189,7 @@ static void init_mqd(struct mqd_manager *mm, void **mqd,
(1 << COMPUTE_PGM_RSRC2__TRAP_PRESENT__SHIFT); (1 << COMPUTE_PGM_RSRC2__TRAP_PRESENT__SHIFT);
} }
if (mm->dev->cwsr_enabled && q->ctx_save_restore_area_address) { if (mm->dev->kfd->cwsr_enabled && q->ctx_save_restore_area_address) {
m->cp_hqd_persistent_state |= m->cp_hqd_persistent_state |=
(1 << CP_HQD_PERSISTENT_STATE__QSWITCH_MODE__SHIFT); (1 << CP_HQD_PERSISTENT_STATE__QSWITCH_MODE__SHIFT);
m->cp_hqd_ctx_save_base_addr_lo = m->cp_hqd_ctx_save_base_addr_lo =
...@@ -225,7 +224,6 @@ static void update_mqd(struct mqd_manager *mm, void *mqd, ...@@ -225,7 +224,6 @@ static void update_mqd(struct mqd_manager *mm, void *mqd,
struct queue_properties *q, struct queue_properties *q,
struct mqd_update_info *minfo) struct mqd_update_info *minfo)
{ {
struct amdgpu_device *adev = (struct amdgpu_device *)mm->dev->adev;
struct v9_mqd *m; struct v9_mqd *m;
m = get_mqd(mqd); m = get_mqd(mqd);
...@@ -275,13 +273,13 @@ static void update_mqd(struct mqd_manager *mm, void *mqd, ...@@ -275,13 +273,13 @@ static void update_mqd(struct mqd_manager *mm, void *mqd,
2 << CP_HQD_PQ_CONTROL__SLOT_BASED_WPTR__SHIFT | 2 << CP_HQD_PQ_CONTROL__SLOT_BASED_WPTR__SHIFT |
1 << CP_HQD_PQ_CONTROL__QUEUE_FULL_EN__SHIFT | 1 << CP_HQD_PQ_CONTROL__QUEUE_FULL_EN__SHIFT |
1 << CP_HQD_PQ_CONTROL__WPP_CLAMP_EN__SHIFT; 1 << CP_HQD_PQ_CONTROL__WPP_CLAMP_EN__SHIFT;
if (adev->ip_versions[GC_HWIP][0] != IP_VERSION(9, 4, 3)) if (KFD_GC_VERSION(mm->dev) != IP_VERSION(9, 4, 3))
m->cp_hqd_pq_control |= m->cp_hqd_pq_control |=
CP_HQD_PQ_CONTROL__NO_UPDATE_RPTR_MASK; CP_HQD_PQ_CONTROL__NO_UPDATE_RPTR_MASK;
m->cp_hqd_pq_doorbell_control |= 1 << m->cp_hqd_pq_doorbell_control |= 1 <<
CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_BIF_DROP__SHIFT; CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_BIF_DROP__SHIFT;
} }
if (mm->dev->cwsr_enabled && q->ctx_save_restore_area_address) if (mm->dev->kfd->cwsr_enabled && q->ctx_save_restore_area_address)
m->cp_hqd_ctx_save_control = 0; m->cp_hqd_ctx_save_control = 0;
update_cu_mask(mm, mqd, minfo); update_cu_mask(mm, mqd, minfo);
...@@ -487,7 +485,7 @@ static int debugfs_show_mqd_sdma(struct seq_file *m, void *data) ...@@ -487,7 +485,7 @@ static int debugfs_show_mqd_sdma(struct seq_file *m, void *data)
#endif #endif
struct mqd_manager *mqd_manager_init_v9(enum KFD_MQD_TYPE type, struct mqd_manager *mqd_manager_init_v9(enum KFD_MQD_TYPE type,
struct kfd_dev *dev) struct kfd_node *dev)
{ {
struct mqd_manager *mqd; struct mqd_manager *mqd;
......
...@@ -77,7 +77,7 @@ static void set_priority(struct vi_mqd *m, struct queue_properties *q) ...@@ -77,7 +77,7 @@ static void set_priority(struct vi_mqd *m, struct queue_properties *q)
m->cp_hqd_queue_priority = q->priority; m->cp_hqd_queue_priority = q->priority;
} }
static struct kfd_mem_obj *allocate_mqd(struct kfd_dev *kfd, static struct kfd_mem_obj *allocate_mqd(struct kfd_node *kfd,
struct queue_properties *q) struct queue_properties *q)
{ {
struct kfd_mem_obj *mqd_mem_obj; struct kfd_mem_obj *mqd_mem_obj;
...@@ -136,7 +136,7 @@ static void init_mqd(struct mqd_manager *mm, void **mqd, ...@@ -136,7 +136,7 @@ static void init_mqd(struct mqd_manager *mm, void **mqd,
(1 << COMPUTE_PGM_RSRC2__TRAP_PRESENT__SHIFT); (1 << COMPUTE_PGM_RSRC2__TRAP_PRESENT__SHIFT);
} }
if (mm->dev->cwsr_enabled && q->ctx_save_restore_area_address) { if (mm->dev->kfd->cwsr_enabled && q->ctx_save_restore_area_address) {
m->cp_hqd_persistent_state |= m->cp_hqd_persistent_state |=
(1 << CP_HQD_PERSISTENT_STATE__QSWITCH_MODE__SHIFT); (1 << CP_HQD_PERSISTENT_STATE__QSWITCH_MODE__SHIFT);
m->cp_hqd_ctx_save_base_addr_lo = m->cp_hqd_ctx_save_base_addr_lo =
...@@ -227,7 +227,7 @@ static void __update_mqd(struct mqd_manager *mm, void *mqd, ...@@ -227,7 +227,7 @@ static void __update_mqd(struct mqd_manager *mm, void *mqd,
2 << CP_HQD_PQ_CONTROL__SLOT_BASED_WPTR__SHIFT; 2 << CP_HQD_PQ_CONTROL__SLOT_BASED_WPTR__SHIFT;
} }
if (mm->dev->cwsr_enabled && q->ctx_save_restore_area_address) if (mm->dev->kfd->cwsr_enabled && q->ctx_save_restore_area_address)
m->cp_hqd_ctx_save_control = m->cp_hqd_ctx_save_control =
atc_bit << CP_HQD_CTX_SAVE_CONTROL__ATC__SHIFT | atc_bit << CP_HQD_CTX_SAVE_CONTROL__ATC__SHIFT |
mtype << CP_HQD_CTX_SAVE_CONTROL__MTYPE__SHIFT; mtype << CP_HQD_CTX_SAVE_CONTROL__MTYPE__SHIFT;
...@@ -446,7 +446,7 @@ static int debugfs_show_mqd_sdma(struct seq_file *m, void *data) ...@@ -446,7 +446,7 @@ static int debugfs_show_mqd_sdma(struct seq_file *m, void *data)
#endif #endif
struct mqd_manager *mqd_manager_init_vi(enum KFD_MQD_TYPE type, struct mqd_manager *mqd_manager_init_vi(enum KFD_MQD_TYPE type,
struct kfd_dev *dev) struct kfd_node *dev)
{ {
struct mqd_manager *mqd; struct mqd_manager *mqd;
...@@ -528,7 +528,7 @@ struct mqd_manager *mqd_manager_init_vi(enum KFD_MQD_TYPE type, ...@@ -528,7 +528,7 @@ struct mqd_manager *mqd_manager_init_vi(enum KFD_MQD_TYPE type,
} }
struct mqd_manager *mqd_manager_init_vi_tonga(enum KFD_MQD_TYPE type, struct mqd_manager *mqd_manager_init_vi_tonga(enum KFD_MQD_TYPE type,
struct kfd_dev *dev) struct kfd_node *dev)
{ {
struct mqd_manager *mqd; struct mqd_manager *mqd;
......
...@@ -45,7 +45,7 @@ static void pm_calc_rlib_size(struct packet_manager *pm, ...@@ -45,7 +45,7 @@ static void pm_calc_rlib_size(struct packet_manager *pm,
unsigned int process_count, queue_count, compute_queue_count, gws_queue_count; unsigned int process_count, queue_count, compute_queue_count, gws_queue_count;
unsigned int map_queue_size; unsigned int map_queue_size;
unsigned int max_proc_per_quantum = 1; unsigned int max_proc_per_quantum = 1;
struct kfd_dev *dev = pm->dqm->dev; struct kfd_node *dev = pm->dqm->dev;
process_count = pm->dqm->processes_count; process_count = pm->dqm->processes_count;
queue_count = pm->dqm->active_queue_count; queue_count = pm->dqm->active_queue_count;
......
...@@ -119,7 +119,7 @@ static int pm_runlist_v9(struct packet_manager *pm, uint32_t *buffer, ...@@ -119,7 +119,7 @@ static int pm_runlist_v9(struct packet_manager *pm, uint32_t *buffer,
struct pm4_mes_runlist *packet; struct pm4_mes_runlist *packet;
int concurrent_proc_cnt = 0; int concurrent_proc_cnt = 0;
struct kfd_dev *kfd = pm->dqm->dev; struct kfd_node *kfd = pm->dqm->dev;
/* Determine the number of processes to map together to HW: /* Determine the number of processes to map together to HW:
* it can not exceed the number of VMIDs available to the * it can not exceed the number of VMIDs available to the
...@@ -220,7 +220,8 @@ static int pm_map_queues_v9(struct packet_manager *pm, uint32_t *buffer, ...@@ -220,7 +220,8 @@ static int pm_map_queues_v9(struct packet_manager *pm, uint32_t *buffer,
case KFD_QUEUE_TYPE_SDMA: case KFD_QUEUE_TYPE_SDMA:
case KFD_QUEUE_TYPE_SDMA_XGMI: case KFD_QUEUE_TYPE_SDMA_XGMI:
use_static = false; /* no static queues under SDMA */ use_static = false; /* no static queues under SDMA */
if (q->properties.sdma_engine_id < 2 && !pm_use_ext_eng(q->device)) if (q->properties.sdma_engine_id < 2 &&
!pm_use_ext_eng(q->device->kfd))
packet->bitfields2.engine_sel = q->properties.sdma_engine_id + packet->bitfields2.engine_sel = q->properties.sdma_engine_id +
engine_sel__mes_map_queues__sdma0_vi; engine_sel__mes_map_queues__sdma0_vi;
else { else {
...@@ -263,7 +264,8 @@ static int pm_unmap_queues_v9(struct packet_manager *pm, uint32_t *buffer, ...@@ -263,7 +264,8 @@ static int pm_unmap_queues_v9(struct packet_manager *pm, uint32_t *buffer,
packet->header.u32All = pm_build_pm4_header(IT_UNMAP_QUEUES, packet->header.u32All = pm_build_pm4_header(IT_UNMAP_QUEUES,
sizeof(struct pm4_mes_unmap_queues)); sizeof(struct pm4_mes_unmap_queues));
packet->bitfields2.extended_engine_sel = pm_use_ext_eng(pm->dqm->dev) ? packet->bitfields2.extended_engine_sel =
pm_use_ext_eng(pm->dqm->dev->kfd) ?
extended_engine_sel__mes_unmap_queues__sdma0_to_7_sel : extended_engine_sel__mes_unmap_queues__sdma0_to_7_sel :
extended_engine_sel__mes_unmap_queues__legacy_engine_sel; extended_engine_sel__mes_unmap_queues__legacy_engine_sel;
......
...@@ -77,7 +77,7 @@ static int pm_runlist_vi(struct packet_manager *pm, uint32_t *buffer, ...@@ -77,7 +77,7 @@ static int pm_runlist_vi(struct packet_manager *pm, uint32_t *buffer,
{ {
struct pm4_mes_runlist *packet; struct pm4_mes_runlist *packet;
int concurrent_proc_cnt = 0; int concurrent_proc_cnt = 0;
struct kfd_dev *kfd = pm->dqm->dev; struct kfd_node *kfd = pm->dqm->dev;
if (WARN_ON(!ib)) if (WARN_ON(!ib))
return -EFAULT; return -EFAULT;
......
This diff is collapsed.
...@@ -269,7 +269,7 @@ static int kfd_get_cu_occupancy(struct attribute *attr, char *buffer) ...@@ -269,7 +269,7 @@ static int kfd_get_cu_occupancy(struct attribute *attr, char *buffer)
int cu_cnt; int cu_cnt;
int wave_cnt; int wave_cnt;
int max_waves_per_cu; int max_waves_per_cu;
struct kfd_dev *dev = NULL; struct kfd_node *dev = NULL;
struct kfd_process *proc = NULL; struct kfd_process *proc = NULL;
struct kfd_process_device *pdd = NULL; struct kfd_process_device *pdd = NULL;
...@@ -691,7 +691,7 @@ void kfd_process_destroy_wq(void) ...@@ -691,7 +691,7 @@ void kfd_process_destroy_wq(void)
static void kfd_process_free_gpuvm(struct kgd_mem *mem, static void kfd_process_free_gpuvm(struct kgd_mem *mem,
struct kfd_process_device *pdd, void **kptr) struct kfd_process_device *pdd, void **kptr)
{ {
struct kfd_dev *dev = pdd->dev; struct kfd_node *dev = pdd->dev;
if (kptr && *kptr) { if (kptr && *kptr) {
amdgpu_amdkfd_gpuvm_unmap_gtt_bo_from_kernel(mem); amdgpu_amdkfd_gpuvm_unmap_gtt_bo_from_kernel(mem);
...@@ -713,7 +713,7 @@ static int kfd_process_alloc_gpuvm(struct kfd_process_device *pdd, ...@@ -713,7 +713,7 @@ static int kfd_process_alloc_gpuvm(struct kfd_process_device *pdd,
uint64_t gpu_va, uint32_t size, uint64_t gpu_va, uint32_t size,
uint32_t flags, struct kgd_mem **mem, void **kptr) uint32_t flags, struct kgd_mem **mem, void **kptr)
{ {
struct kfd_dev *kdev = pdd->dev; struct kfd_node *kdev = pdd->dev;
int err; int err;
err = amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(kdev->adev, gpu_va, size, err = amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(kdev->adev, gpu_va, size,
...@@ -982,7 +982,7 @@ static void kfd_process_device_free_bos(struct kfd_process_device *pdd) ...@@ -982,7 +982,7 @@ static void kfd_process_device_free_bos(struct kfd_process_device *pdd)
static void kfd_process_kunmap_signal_bo(struct kfd_process *p) static void kfd_process_kunmap_signal_bo(struct kfd_process *p)
{ {
struct kfd_process_device *pdd; struct kfd_process_device *pdd;
struct kfd_dev *kdev; struct kfd_node *kdev;
void *mem; void *mem;
kdev = kfd_device_by_id(GET_GPU_ID(p->signal_handle)); kdev = kfd_device_by_id(GET_GPU_ID(p->signal_handle));
...@@ -1040,9 +1040,9 @@ static void kfd_process_destroy_pdds(struct kfd_process *p) ...@@ -1040,9 +1040,9 @@ static void kfd_process_destroy_pdds(struct kfd_process *p)
bitmap_free(pdd->qpd.doorbell_bitmap); bitmap_free(pdd->qpd.doorbell_bitmap);
idr_destroy(&pdd->alloc_idr); idr_destroy(&pdd->alloc_idr);
kfd_free_process_doorbells(pdd->dev, pdd->doorbell_index); kfd_free_process_doorbells(pdd->dev->kfd, pdd->doorbell_index);
if (pdd->dev->shared_resources.enable_mes) if (pdd->dev->kfd->shared_resources.enable_mes)
amdgpu_amdkfd_free_gtt_mem(pdd->dev->adev, amdgpu_amdkfd_free_gtt_mem(pdd->dev->adev,
pdd->proc_ctx_bo); pdd->proc_ctx_bo);
/* /*
...@@ -1259,10 +1259,10 @@ static int kfd_process_init_cwsr_apu(struct kfd_process *p, struct file *filep) ...@@ -1259,10 +1259,10 @@ static int kfd_process_init_cwsr_apu(struct kfd_process *p, struct file *filep)
int i; int i;
for (i = 0; i < p->n_pdds; i++) { for (i = 0; i < p->n_pdds; i++) {
struct kfd_dev *dev = p->pdds[i]->dev; struct kfd_node *dev = p->pdds[i]->dev;
struct qcm_process_device *qpd = &p->pdds[i]->qpd; struct qcm_process_device *qpd = &p->pdds[i]->qpd;
if (!dev->cwsr_enabled || qpd->cwsr_kaddr || qpd->cwsr_base) if (!dev->kfd->cwsr_enabled || qpd->cwsr_kaddr || qpd->cwsr_base)
continue; continue;
offset = KFD_MMAP_TYPE_RESERVED_MEM | KFD_MMAP_GPU_ID(dev->id); offset = KFD_MMAP_TYPE_RESERVED_MEM | KFD_MMAP_GPU_ID(dev->id);
...@@ -1279,7 +1279,7 @@ static int kfd_process_init_cwsr_apu(struct kfd_process *p, struct file *filep) ...@@ -1279,7 +1279,7 @@ static int kfd_process_init_cwsr_apu(struct kfd_process *p, struct file *filep)
return err; return err;
} }
memcpy(qpd->cwsr_kaddr, dev->cwsr_isa, dev->cwsr_isa_size); memcpy(qpd->cwsr_kaddr, dev->kfd->cwsr_isa, dev->kfd->cwsr_isa_size);
qpd->tma_addr = qpd->tba_addr + KFD_CWSR_TMA_OFFSET; qpd->tma_addr = qpd->tba_addr + KFD_CWSR_TMA_OFFSET;
pr_debug("set tba :0x%llx, tma:0x%llx, cwsr_kaddr:%p for pqm.\n", pr_debug("set tba :0x%llx, tma:0x%llx, cwsr_kaddr:%p for pqm.\n",
...@@ -1291,7 +1291,7 @@ static int kfd_process_init_cwsr_apu(struct kfd_process *p, struct file *filep) ...@@ -1291,7 +1291,7 @@ static int kfd_process_init_cwsr_apu(struct kfd_process *p, struct file *filep)
static int kfd_process_device_init_cwsr_dgpu(struct kfd_process_device *pdd) static int kfd_process_device_init_cwsr_dgpu(struct kfd_process_device *pdd)
{ {
struct kfd_dev *dev = pdd->dev; struct kfd_node *dev = pdd->dev;
struct qcm_process_device *qpd = &pdd->qpd; struct qcm_process_device *qpd = &pdd->qpd;
uint32_t flags = KFD_IOC_ALLOC_MEM_FLAGS_GTT uint32_t flags = KFD_IOC_ALLOC_MEM_FLAGS_GTT
| KFD_IOC_ALLOC_MEM_FLAGS_NO_SUBSTITUTE | KFD_IOC_ALLOC_MEM_FLAGS_NO_SUBSTITUTE
...@@ -1300,7 +1300,7 @@ static int kfd_process_device_init_cwsr_dgpu(struct kfd_process_device *pdd) ...@@ -1300,7 +1300,7 @@ static int kfd_process_device_init_cwsr_dgpu(struct kfd_process_device *pdd)
void *kaddr; void *kaddr;
int ret; int ret;
if (!dev->cwsr_enabled || qpd->cwsr_kaddr || !qpd->cwsr_base) if (!dev->kfd->cwsr_enabled || qpd->cwsr_kaddr || !qpd->cwsr_base)
return 0; return 0;
/* cwsr_base is only set for dGPU */ /* cwsr_base is only set for dGPU */
...@@ -1313,7 +1313,7 @@ static int kfd_process_device_init_cwsr_dgpu(struct kfd_process_device *pdd) ...@@ -1313,7 +1313,7 @@ static int kfd_process_device_init_cwsr_dgpu(struct kfd_process_device *pdd)
qpd->cwsr_kaddr = kaddr; qpd->cwsr_kaddr = kaddr;
qpd->tba_addr = qpd->cwsr_base; qpd->tba_addr = qpd->cwsr_base;
memcpy(qpd->cwsr_kaddr, dev->cwsr_isa, dev->cwsr_isa_size); memcpy(qpd->cwsr_kaddr, dev->kfd->cwsr_isa, dev->kfd->cwsr_isa_size);
qpd->tma_addr = qpd->tba_addr + KFD_CWSR_TMA_OFFSET; qpd->tma_addr = qpd->tba_addr + KFD_CWSR_TMA_OFFSET;
pr_debug("set tba :0x%llx, tma:0x%llx, cwsr_kaddr:%p for pqm.\n", pr_debug("set tba :0x%llx, tma:0x%llx, cwsr_kaddr:%p for pqm.\n",
...@@ -1324,10 +1324,10 @@ static int kfd_process_device_init_cwsr_dgpu(struct kfd_process_device *pdd) ...@@ -1324,10 +1324,10 @@ static int kfd_process_device_init_cwsr_dgpu(struct kfd_process_device *pdd)
static void kfd_process_device_destroy_cwsr_dgpu(struct kfd_process_device *pdd) static void kfd_process_device_destroy_cwsr_dgpu(struct kfd_process_device *pdd)
{ {
struct kfd_dev *dev = pdd->dev; struct kfd_node *dev = pdd->dev;
struct qcm_process_device *qpd = &pdd->qpd; struct qcm_process_device *qpd = &pdd->qpd;
if (!dev->cwsr_enabled || !qpd->cwsr_kaddr || !qpd->cwsr_base) if (!dev->kfd->cwsr_enabled || !qpd->cwsr_kaddr || !qpd->cwsr_base)
return; return;
kfd_process_free_gpuvm(qpd->cwsr_mem, pdd, &qpd->cwsr_kaddr); kfd_process_free_gpuvm(qpd->cwsr_mem, pdd, &qpd->cwsr_kaddr);
...@@ -1371,7 +1371,7 @@ bool kfd_process_xnack_mode(struct kfd_process *p, bool supported) ...@@ -1371,7 +1371,7 @@ bool kfd_process_xnack_mode(struct kfd_process *p, bool supported)
* support retry. * support retry.
*/ */
for (i = 0; i < p->n_pdds; i++) { for (i = 0; i < p->n_pdds; i++) {
struct kfd_dev *dev = p->pdds[i]->dev; struct kfd_node *dev = p->pdds[i]->dev;
/* Only consider GFXv9 and higher GPUs. Older GPUs don't /* Only consider GFXv9 and higher GPUs. Older GPUs don't
* support the SVM APIs and don't need to be considered * support the SVM APIs and don't need to be considered
...@@ -1394,7 +1394,7 @@ bool kfd_process_xnack_mode(struct kfd_process *p, bool supported) ...@@ -1394,7 +1394,7 @@ bool kfd_process_xnack_mode(struct kfd_process *p, bool supported)
if (KFD_GC_VERSION(dev) >= IP_VERSION(10, 1, 1)) if (KFD_GC_VERSION(dev) >= IP_VERSION(10, 1, 1))
return false; return false;
if (dev->noretry) if (dev->kfd->noretry)
return false; return false;
} }
...@@ -1528,7 +1528,7 @@ static int init_doorbell_bitmap(struct qcm_process_device *qpd, ...@@ -1528,7 +1528,7 @@ static int init_doorbell_bitmap(struct qcm_process_device *qpd,
return 0; return 0;
} }
struct kfd_process_device *kfd_get_process_device_data(struct kfd_dev *dev, struct kfd_process_device *kfd_get_process_device_data(struct kfd_node *dev,
struct kfd_process *p) struct kfd_process *p)
{ {
int i; int i;
...@@ -1540,7 +1540,7 @@ struct kfd_process_device *kfd_get_process_device_data(struct kfd_dev *dev, ...@@ -1540,7 +1540,7 @@ struct kfd_process_device *kfd_get_process_device_data(struct kfd_dev *dev,
return NULL; return NULL;
} }
struct kfd_process_device *kfd_create_process_device_data(struct kfd_dev *dev, struct kfd_process_device *kfd_create_process_device_data(struct kfd_node *dev,
struct kfd_process *p) struct kfd_process *p)
{ {
struct kfd_process_device *pdd = NULL; struct kfd_process_device *pdd = NULL;
...@@ -1552,7 +1552,7 @@ struct kfd_process_device *kfd_create_process_device_data(struct kfd_dev *dev, ...@@ -1552,7 +1552,7 @@ struct kfd_process_device *kfd_create_process_device_data(struct kfd_dev *dev,
if (!pdd) if (!pdd)
return NULL; return NULL;
if (init_doorbell_bitmap(&pdd->qpd, dev)) { if (init_doorbell_bitmap(&pdd->qpd, dev->kfd)) {
pr_err("Failed to init doorbell for process\n"); pr_err("Failed to init doorbell for process\n");
goto err_free_pdd; goto err_free_pdd;
} }
...@@ -1573,7 +1573,7 @@ struct kfd_process_device *kfd_create_process_device_data(struct kfd_dev *dev, ...@@ -1573,7 +1573,7 @@ struct kfd_process_device *kfd_create_process_device_data(struct kfd_dev *dev,
pdd->user_gpu_id = dev->id; pdd->user_gpu_id = dev->id;
atomic64_set(&pdd->evict_duration_counter, 0); atomic64_set(&pdd->evict_duration_counter, 0);
if (dev->shared_resources.enable_mes) { if (dev->kfd->shared_resources.enable_mes) {
retval = amdgpu_amdkfd_alloc_gtt_mem(dev->adev, retval = amdgpu_amdkfd_alloc_gtt_mem(dev->adev,
AMDGPU_MES_PROC_CTX_SIZE, AMDGPU_MES_PROC_CTX_SIZE,
&pdd->proc_ctx_bo, &pdd->proc_ctx_bo,
...@@ -1619,7 +1619,7 @@ int kfd_process_device_init_vm(struct kfd_process_device *pdd, ...@@ -1619,7 +1619,7 @@ int kfd_process_device_init_vm(struct kfd_process_device *pdd,
struct amdgpu_fpriv *drv_priv; struct amdgpu_fpriv *drv_priv;
struct amdgpu_vm *avm; struct amdgpu_vm *avm;
struct kfd_process *p; struct kfd_process *p;
struct kfd_dev *dev; struct kfd_node *dev;
int ret; int ret;
if (!drm_file) if (!drm_file)
...@@ -1679,7 +1679,7 @@ int kfd_process_device_init_vm(struct kfd_process_device *pdd, ...@@ -1679,7 +1679,7 @@ int kfd_process_device_init_vm(struct kfd_process_device *pdd,
* *
* Assumes that the process lock is held. * Assumes that the process lock is held.
*/ */
struct kfd_process_device *kfd_bind_process_to_device(struct kfd_dev *dev, struct kfd_process_device *kfd_bind_process_to_device(struct kfd_node *dev,
struct kfd_process *p) struct kfd_process *p)
{ {
struct kfd_process_device *pdd; struct kfd_process_device *pdd;
...@@ -1811,7 +1811,7 @@ int kfd_process_evict_queues(struct kfd_process *p, uint32_t trigger) ...@@ -1811,7 +1811,7 @@ int kfd_process_evict_queues(struct kfd_process *p, uint32_t trigger)
for (i = 0; i < p->n_pdds; i++) { for (i = 0; i < p->n_pdds; i++) {
struct kfd_process_device *pdd = p->pdds[i]; struct kfd_process_device *pdd = p->pdds[i];
kfd_smi_event_queue_eviction(pdd->dev, p->lead_thread->pid, kfd_smi_event_queue_eviction(pdd->dev->kfd, p->lead_thread->pid,
trigger); trigger);
r = pdd->dev->dqm->ops.evict_process_queues(pdd->dev->dqm, r = pdd->dev->dqm->ops.evict_process_queues(pdd->dev->dqm,
...@@ -1839,7 +1839,7 @@ int kfd_process_evict_queues(struct kfd_process *p, uint32_t trigger) ...@@ -1839,7 +1839,7 @@ int kfd_process_evict_queues(struct kfd_process *p, uint32_t trigger)
if (n_evicted == 0) if (n_evicted == 0)
break; break;
kfd_smi_event_queue_restore(pdd->dev, p->lead_thread->pid); kfd_smi_event_queue_restore(pdd->dev->kfd, p->lead_thread->pid);
if (pdd->dev->dqm->ops.restore_process_queues(pdd->dev->dqm, if (pdd->dev->dqm->ops.restore_process_queues(pdd->dev->dqm,
&pdd->qpd)) &pdd->qpd))
...@@ -1860,7 +1860,7 @@ int kfd_process_restore_queues(struct kfd_process *p) ...@@ -1860,7 +1860,7 @@ int kfd_process_restore_queues(struct kfd_process *p)
for (i = 0; i < p->n_pdds; i++) { for (i = 0; i < p->n_pdds; i++) {
struct kfd_process_device *pdd = p->pdds[i]; struct kfd_process_device *pdd = p->pdds[i];
kfd_smi_event_queue_restore(pdd->dev, p->lead_thread->pid); kfd_smi_event_queue_restore(pdd->dev->kfd, p->lead_thread->pid);
r = pdd->dev->dqm->ops.restore_process_queues(pdd->dev->dqm, r = pdd->dev->dqm->ops.restore_process_queues(pdd->dev->dqm,
&pdd->qpd); &pdd->qpd);
...@@ -2016,7 +2016,7 @@ int kfd_resume_all_processes(void) ...@@ -2016,7 +2016,7 @@ int kfd_resume_all_processes(void)
return ret; return ret;
} }
int kfd_reserved_mem_mmap(struct kfd_dev *dev, struct kfd_process *process, int kfd_reserved_mem_mmap(struct kfd_node *dev, struct kfd_process *process,
struct vm_area_struct *vma) struct vm_area_struct *vma)
{ {
struct kfd_process_device *pdd; struct kfd_process_device *pdd;
...@@ -2051,7 +2051,7 @@ void kfd_flush_tlb(struct kfd_process_device *pdd, enum TLB_FLUSH_TYPE type) ...@@ -2051,7 +2051,7 @@ void kfd_flush_tlb(struct kfd_process_device *pdd, enum TLB_FLUSH_TYPE type)
{ {
struct amdgpu_vm *vm = drm_priv_to_vm(pdd->drm_priv); struct amdgpu_vm *vm = drm_priv_to_vm(pdd->drm_priv);
uint64_t tlb_seq = amdgpu_vm_tlb_seq(vm); uint64_t tlb_seq = amdgpu_vm_tlb_seq(vm);
struct kfd_dev *dev = pdd->dev; struct kfd_node *dev = pdd->dev;
/* /*
* It can be that we race and lose here, but that is extremely unlikely * It can be that we race and lose here, but that is extremely unlikely
......
...@@ -81,7 +81,7 @@ static int find_available_queue_slot(struct process_queue_manager *pqm, ...@@ -81,7 +81,7 @@ static int find_available_queue_slot(struct process_queue_manager *pqm,
void kfd_process_dequeue_from_device(struct kfd_process_device *pdd) void kfd_process_dequeue_from_device(struct kfd_process_device *pdd)
{ {
struct kfd_dev *dev = pdd->dev; struct kfd_node *dev = pdd->dev;
if (pdd->already_dequeued) if (pdd->already_dequeued)
return; return;
...@@ -93,7 +93,7 @@ void kfd_process_dequeue_from_device(struct kfd_process_device *pdd) ...@@ -93,7 +93,7 @@ void kfd_process_dequeue_from_device(struct kfd_process_device *pdd)
int pqm_set_gws(struct process_queue_manager *pqm, unsigned int qid, int pqm_set_gws(struct process_queue_manager *pqm, unsigned int qid,
void *gws) void *gws)
{ {
struct kfd_dev *dev = NULL; struct kfd_node *dev = NULL;
struct process_queue_node *pqn; struct process_queue_node *pqn;
struct kfd_process_device *pdd; struct kfd_process_device *pdd;
struct kgd_mem *mem = NULL; struct kgd_mem *mem = NULL;
...@@ -178,7 +178,7 @@ void pqm_uninit(struct process_queue_manager *pqm) ...@@ -178,7 +178,7 @@ void pqm_uninit(struct process_queue_manager *pqm)
} }
static int init_user_queue(struct process_queue_manager *pqm, static int init_user_queue(struct process_queue_manager *pqm,
struct kfd_dev *dev, struct queue **q, struct kfd_node *dev, struct queue **q,
struct queue_properties *q_properties, struct queue_properties *q_properties,
struct file *f, struct amdgpu_bo *wptr_bo, struct file *f, struct amdgpu_bo *wptr_bo,
unsigned int qid) unsigned int qid)
...@@ -199,7 +199,7 @@ static int init_user_queue(struct process_queue_manager *pqm, ...@@ -199,7 +199,7 @@ static int init_user_queue(struct process_queue_manager *pqm,
(*q)->device = dev; (*q)->device = dev;
(*q)->process = pqm->process; (*q)->process = pqm->process;
if (dev->shared_resources.enable_mes) { if (dev->kfd->shared_resources.enable_mes) {
retval = amdgpu_amdkfd_alloc_gtt_mem(dev->adev, retval = amdgpu_amdkfd_alloc_gtt_mem(dev->adev,
AMDGPU_MES_GANG_CTX_SIZE, AMDGPU_MES_GANG_CTX_SIZE,
&(*q)->gang_ctx_bo, &(*q)->gang_ctx_bo,
...@@ -224,7 +224,7 @@ static int init_user_queue(struct process_queue_manager *pqm, ...@@ -224,7 +224,7 @@ static int init_user_queue(struct process_queue_manager *pqm,
} }
int pqm_create_queue(struct process_queue_manager *pqm, int pqm_create_queue(struct process_queue_manager *pqm,
struct kfd_dev *dev, struct kfd_node *dev,
struct file *f, struct file *f,
struct queue_properties *properties, struct queue_properties *properties,
unsigned int *qid, unsigned int *qid,
...@@ -258,7 +258,7 @@ int pqm_create_queue(struct process_queue_manager *pqm, ...@@ -258,7 +258,7 @@ int pqm_create_queue(struct process_queue_manager *pqm,
* Hence we also check the type as well * Hence we also check the type as well
*/ */
if ((pdd->qpd.is_debug) || (type == KFD_QUEUE_TYPE_DIQ)) if ((pdd->qpd.is_debug) || (type == KFD_QUEUE_TYPE_DIQ))
max_queues = dev->device_info.max_no_of_hqd/2; max_queues = dev->kfd->device_info.max_no_of_hqd/2;
if (pdd->qpd.queue_count >= max_queues) if (pdd->qpd.queue_count >= max_queues)
return -ENOSPC; return -ENOSPC;
...@@ -354,7 +354,7 @@ int pqm_create_queue(struct process_queue_manager *pqm, ...@@ -354,7 +354,7 @@ int pqm_create_queue(struct process_queue_manager *pqm,
*/ */
*p_doorbell_offset_in_process = *p_doorbell_offset_in_process =
(q->properties.doorbell_off * sizeof(uint32_t)) & (q->properties.doorbell_off * sizeof(uint32_t)) &
(kfd_doorbell_process_slice(dev) - 1); (kfd_doorbell_process_slice(dev->kfd) - 1);
pr_debug("PQM After DQM create queue\n"); pr_debug("PQM After DQM create queue\n");
...@@ -387,7 +387,7 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid) ...@@ -387,7 +387,7 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid)
struct process_queue_node *pqn; struct process_queue_node *pqn;
struct kfd_process_device *pdd; struct kfd_process_device *pdd;
struct device_queue_manager *dqm; struct device_queue_manager *dqm;
struct kfd_dev *dev; struct kfd_node *dev;
int retval; int retval;
dqm = NULL; dqm = NULL;
...@@ -439,7 +439,7 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid) ...@@ -439,7 +439,7 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid)
pdd->qpd.num_gws = 0; pdd->qpd.num_gws = 0;
} }
if (dev->shared_resources.enable_mes) { if (dev->kfd->shared_resources.enable_mes) {
amdgpu_amdkfd_free_gtt_mem(dev->adev, amdgpu_amdkfd_free_gtt_mem(dev->adev,
pqn->q->gang_ctx_bo); pqn->q->gang_ctx_bo);
if (pqn->q->wptr_bo) if (pqn->q->wptr_bo)
...@@ -859,7 +859,7 @@ int kfd_criu_restore_queue(struct kfd_process *p, ...@@ -859,7 +859,7 @@ int kfd_criu_restore_queue(struct kfd_process *p,
} }
if (!pdd->doorbell_index && if (!pdd->doorbell_index &&
kfd_alloc_process_doorbells(pdd->dev, &pdd->doorbell_index) < 0) { kfd_alloc_process_doorbells(pdd->dev->kfd, &pdd->doorbell_index) < 0) {
ret = -ENOMEM; ret = -ENOMEM;
goto exit; goto exit;
} }
......
...@@ -36,7 +36,7 @@ struct kfd_smi_client { ...@@ -36,7 +36,7 @@ struct kfd_smi_client {
wait_queue_head_t wait_queue; wait_queue_head_t wait_queue;
/* events enabled */ /* events enabled */
uint64_t events; uint64_t events;
struct kfd_dev *dev; struct kfd_node *dev;
spinlock_t lock; spinlock_t lock;
struct rcu_head rcu; struct rcu_head rcu;
pid_t pid; pid_t pid;
...@@ -149,7 +149,7 @@ static void kfd_smi_ev_client_free(struct rcu_head *p) ...@@ -149,7 +149,7 @@ static void kfd_smi_ev_client_free(struct rcu_head *p)
static int kfd_smi_ev_release(struct inode *inode, struct file *filep) static int kfd_smi_ev_release(struct inode *inode, struct file *filep)
{ {
struct kfd_smi_client *client = filep->private_data; struct kfd_smi_client *client = filep->private_data;
struct kfd_dev *dev = client->dev; struct kfd_node *dev = client->dev;
spin_lock(&dev->smi_lock); spin_lock(&dev->smi_lock);
list_del_rcu(&client->list); list_del_rcu(&client->list);
...@@ -171,7 +171,7 @@ static bool kfd_smi_ev_enabled(pid_t pid, struct kfd_smi_client *client, ...@@ -171,7 +171,7 @@ static bool kfd_smi_ev_enabled(pid_t pid, struct kfd_smi_client *client,
return events & KFD_SMI_EVENT_MASK_FROM_INDEX(event); return events & KFD_SMI_EVENT_MASK_FROM_INDEX(event);
} }
static void add_event_to_kfifo(pid_t pid, struct kfd_dev *dev, static void add_event_to_kfifo(pid_t pid, struct kfd_node *dev,
unsigned int smi_event, char *event_msg, int len) unsigned int smi_event, char *event_msg, int len)
{ {
struct kfd_smi_client *client; struct kfd_smi_client *client;
...@@ -196,7 +196,7 @@ static void add_event_to_kfifo(pid_t pid, struct kfd_dev *dev, ...@@ -196,7 +196,7 @@ static void add_event_to_kfifo(pid_t pid, struct kfd_dev *dev,
} }
__printf(4, 5) __printf(4, 5)
static void kfd_smi_event_add(pid_t pid, struct kfd_dev *dev, static void kfd_smi_event_add(pid_t pid, struct kfd_node *dev,
unsigned int event, char *fmt, ...) unsigned int event, char *fmt, ...)
{ {
char fifo_in[KFD_SMI_EVENT_MSG_SIZE]; char fifo_in[KFD_SMI_EVENT_MSG_SIZE];
...@@ -215,7 +215,7 @@ static void kfd_smi_event_add(pid_t pid, struct kfd_dev *dev, ...@@ -215,7 +215,7 @@ static void kfd_smi_event_add(pid_t pid, struct kfd_dev *dev,
add_event_to_kfifo(pid, dev, event, fifo_in, len); add_event_to_kfifo(pid, dev, event, fifo_in, len);
} }
void kfd_smi_event_update_gpu_reset(struct kfd_dev *dev, bool post_reset) void kfd_smi_event_update_gpu_reset(struct kfd_node *dev, bool post_reset)
{ {
unsigned int event; unsigned int event;
...@@ -228,7 +228,7 @@ void kfd_smi_event_update_gpu_reset(struct kfd_dev *dev, bool post_reset) ...@@ -228,7 +228,7 @@ void kfd_smi_event_update_gpu_reset(struct kfd_dev *dev, bool post_reset)
kfd_smi_event_add(0, dev, event, "%x\n", dev->reset_seq_num); kfd_smi_event_add(0, dev, event, "%x\n", dev->reset_seq_num);
} }
void kfd_smi_event_update_thermal_throttling(struct kfd_dev *dev, void kfd_smi_event_update_thermal_throttling(struct kfd_node *dev,
uint64_t throttle_bitmask) uint64_t throttle_bitmask)
{ {
kfd_smi_event_add(0, dev, KFD_SMI_EVENT_THERMAL_THROTTLE, "%llx:%llx\n", kfd_smi_event_add(0, dev, KFD_SMI_EVENT_THERMAL_THROTTLE, "%llx:%llx\n",
...@@ -236,7 +236,7 @@ void kfd_smi_event_update_thermal_throttling(struct kfd_dev *dev, ...@@ -236,7 +236,7 @@ void kfd_smi_event_update_thermal_throttling(struct kfd_dev *dev,
amdgpu_dpm_get_thermal_throttling_counter(dev->adev)); amdgpu_dpm_get_thermal_throttling_counter(dev->adev));
} }
void kfd_smi_event_update_vmfault(struct kfd_dev *dev, uint16_t pasid) void kfd_smi_event_update_vmfault(struct kfd_node *dev, uint16_t pasid)
{ {
struct amdgpu_task_info task_info; struct amdgpu_task_info task_info;
...@@ -254,17 +254,17 @@ void kfd_smi_event_page_fault_start(struct kfd_dev *dev, pid_t pid, ...@@ -254,17 +254,17 @@ void kfd_smi_event_page_fault_start(struct kfd_dev *dev, pid_t pid,
unsigned long address, bool write_fault, unsigned long address, bool write_fault,
ktime_t ts) ktime_t ts)
{ {
kfd_smi_event_add(pid, dev, KFD_SMI_EVENT_PAGE_FAULT_START, kfd_smi_event_add(pid, dev->node, KFD_SMI_EVENT_PAGE_FAULT_START,
"%lld -%d @%lx(%x) %c\n", ktime_to_ns(ts), pid, "%lld -%d @%lx(%x) %c\n", ktime_to_ns(ts), pid,
address, dev->id, write_fault ? 'W' : 'R'); address, dev->node->id, write_fault ? 'W' : 'R');
} }
void kfd_smi_event_page_fault_end(struct kfd_dev *dev, pid_t pid, void kfd_smi_event_page_fault_end(struct kfd_dev *dev, pid_t pid,
unsigned long address, bool migration) unsigned long address, bool migration)
{ {
kfd_smi_event_add(pid, dev, KFD_SMI_EVENT_PAGE_FAULT_END, kfd_smi_event_add(pid, dev->node, KFD_SMI_EVENT_PAGE_FAULT_END,
"%lld -%d @%lx(%x) %c\n", ktime_get_boottime_ns(), "%lld -%d @%lx(%x) %c\n", ktime_get_boottime_ns(),
pid, address, dev->id, migration ? 'M' : 'U'); pid, address, dev->node->id, migration ? 'M' : 'U');
} }
void kfd_smi_event_migration_start(struct kfd_dev *dev, pid_t pid, void kfd_smi_event_migration_start(struct kfd_dev *dev, pid_t pid,
...@@ -273,7 +273,7 @@ void kfd_smi_event_migration_start(struct kfd_dev *dev, pid_t pid, ...@@ -273,7 +273,7 @@ void kfd_smi_event_migration_start(struct kfd_dev *dev, pid_t pid,
uint32_t prefetch_loc, uint32_t preferred_loc, uint32_t prefetch_loc, uint32_t preferred_loc,
uint32_t trigger) uint32_t trigger)
{ {
kfd_smi_event_add(pid, dev, KFD_SMI_EVENT_MIGRATE_START, kfd_smi_event_add(pid, dev->node, KFD_SMI_EVENT_MIGRATE_START,
"%lld -%d @%lx(%lx) %x->%x %x:%x %d\n", "%lld -%d @%lx(%lx) %x->%x %x:%x %d\n",
ktime_get_boottime_ns(), pid, start, end - start, ktime_get_boottime_ns(), pid, start, end - start,
from, to, prefetch_loc, preferred_loc, trigger); from, to, prefetch_loc, preferred_loc, trigger);
...@@ -283,7 +283,7 @@ void kfd_smi_event_migration_end(struct kfd_dev *dev, pid_t pid, ...@@ -283,7 +283,7 @@ void kfd_smi_event_migration_end(struct kfd_dev *dev, pid_t pid,
unsigned long start, unsigned long end, unsigned long start, unsigned long end,
uint32_t from, uint32_t to, uint32_t trigger) uint32_t from, uint32_t to, uint32_t trigger)
{ {
kfd_smi_event_add(pid, dev, KFD_SMI_EVENT_MIGRATE_END, kfd_smi_event_add(pid, dev->node, KFD_SMI_EVENT_MIGRATE_END,
"%lld -%d @%lx(%lx) %x->%x %d\n", "%lld -%d @%lx(%lx) %x->%x %d\n",
ktime_get_boottime_ns(), pid, start, end - start, ktime_get_boottime_ns(), pid, start, end - start,
from, to, trigger); from, to, trigger);
...@@ -292,16 +292,16 @@ void kfd_smi_event_migration_end(struct kfd_dev *dev, pid_t pid, ...@@ -292,16 +292,16 @@ void kfd_smi_event_migration_end(struct kfd_dev *dev, pid_t pid,
void kfd_smi_event_queue_eviction(struct kfd_dev *dev, pid_t pid, void kfd_smi_event_queue_eviction(struct kfd_dev *dev, pid_t pid,
uint32_t trigger) uint32_t trigger)
{ {
kfd_smi_event_add(pid, dev, KFD_SMI_EVENT_QUEUE_EVICTION, kfd_smi_event_add(pid, dev->node, KFD_SMI_EVENT_QUEUE_EVICTION,
"%lld -%d %x %d\n", ktime_get_boottime_ns(), pid, "%lld -%d %x %d\n", ktime_get_boottime_ns(), pid,
dev->id, trigger); dev->node->id, trigger);
} }
void kfd_smi_event_queue_restore(struct kfd_dev *dev, pid_t pid) void kfd_smi_event_queue_restore(struct kfd_dev *dev, pid_t pid)
{ {
kfd_smi_event_add(pid, dev, KFD_SMI_EVENT_QUEUE_RESTORE, kfd_smi_event_add(pid, dev->node, KFD_SMI_EVENT_QUEUE_RESTORE,
"%lld -%d %x\n", ktime_get_boottime_ns(), pid, "%lld -%d %x\n", ktime_get_boottime_ns(), pid,
dev->id); dev->node->id);
} }
void kfd_smi_event_queue_restore_rescheduled(struct mm_struct *mm) void kfd_smi_event_queue_restore_rescheduled(struct mm_struct *mm)
...@@ -328,12 +328,12 @@ void kfd_smi_event_unmap_from_gpu(struct kfd_dev *dev, pid_t pid, ...@@ -328,12 +328,12 @@ void kfd_smi_event_unmap_from_gpu(struct kfd_dev *dev, pid_t pid,
unsigned long address, unsigned long last, unsigned long address, unsigned long last,
uint32_t trigger) uint32_t trigger)
{ {
kfd_smi_event_add(pid, dev, KFD_SMI_EVENT_UNMAP_FROM_GPU, kfd_smi_event_add(pid, dev->node, KFD_SMI_EVENT_UNMAP_FROM_GPU,
"%lld -%d @%lx(%lx) %x %d\n", ktime_get_boottime_ns(), "%lld -%d @%lx(%lx) %x %d\n", ktime_get_boottime_ns(),
pid, address, last - address + 1, dev->id, trigger); pid, address, last - address + 1, dev->node->id, trigger);
} }
int kfd_smi_event_open(struct kfd_dev *dev, uint32_t *fd) int kfd_smi_event_open(struct kfd_node *dev, uint32_t *fd)
{ {
struct kfd_smi_client *client; struct kfd_smi_client *client;
int ret; int ret;
......
...@@ -24,11 +24,11 @@ ...@@ -24,11 +24,11 @@
#ifndef KFD_SMI_EVENTS_H_INCLUDED #ifndef KFD_SMI_EVENTS_H_INCLUDED
#define KFD_SMI_EVENTS_H_INCLUDED #define KFD_SMI_EVENTS_H_INCLUDED
int kfd_smi_event_open(struct kfd_dev *dev, uint32_t *fd); int kfd_smi_event_open(struct kfd_node *dev, uint32_t *fd);
void kfd_smi_event_update_vmfault(struct kfd_dev *dev, uint16_t pasid); void kfd_smi_event_update_vmfault(struct kfd_node *dev, uint16_t pasid);
void kfd_smi_event_update_thermal_throttling(struct kfd_dev *dev, void kfd_smi_event_update_thermal_throttling(struct kfd_node *dev,
uint64_t throttle_bitmask); uint64_t throttle_bitmask);
void kfd_smi_event_update_gpu_reset(struct kfd_dev *dev, bool post_reset); void kfd_smi_event_update_gpu_reset(struct kfd_node *dev, bool post_reset);
void kfd_smi_event_page_fault_start(struct kfd_dev *dev, pid_t pid, void kfd_smi_event_page_fault_start(struct kfd_dev *dev, pid_t pid,
unsigned long address, bool write_fault, unsigned long address, bool write_fault,
ktime_t ts); ktime_t ts);
......
...@@ -1266,7 +1266,7 @@ svm_range_unmap_from_gpus(struct svm_range *prange, unsigned long start, ...@@ -1266,7 +1266,7 @@ svm_range_unmap_from_gpus(struct svm_range *prange, unsigned long start,
return -EINVAL; return -EINVAL;
} }
kfd_smi_event_unmap_from_gpu(pdd->dev, p->lead_thread->pid, kfd_smi_event_unmap_from_gpu(pdd->dev->kfd, p->lead_thread->pid,
start, last, trigger); start, last, trigger);
r = svm_range_unmap_from_gpu(pdd->dev->adev, r = svm_range_unmap_from_gpu(pdd->dev->adev,
...@@ -3083,7 +3083,7 @@ int svm_range_list_init(struct kfd_process *p) ...@@ -3083,7 +3083,7 @@ int svm_range_list_init(struct kfd_process *p)
spin_lock_init(&svms->deferred_list_lock); spin_lock_init(&svms->deferred_list_lock);
for (i = 0; i < p->n_pdds; i++) for (i = 0; i < p->n_pdds; i++)
if (KFD_IS_SVM_API_SUPPORTED(p->pdds[i]->dev)) if (KFD_IS_SVM_API_SUPPORTED(p->pdds[i]->dev->kfd))
bitmap_set(svms->bitmap_supported, i, 1); bitmap_set(svms->bitmap_supported, i, 1);
return 0; return 0;
......
...@@ -96,7 +96,7 @@ struct kfd_topology_device *kfd_topology_device_by_id(uint32_t gpu_id) ...@@ -96,7 +96,7 @@ struct kfd_topology_device *kfd_topology_device_by_id(uint32_t gpu_id)
return ret; return ret;
} }
struct kfd_dev *kfd_device_by_id(uint32_t gpu_id) struct kfd_node *kfd_device_by_id(uint32_t gpu_id)
{ {
struct kfd_topology_device *top_dev; struct kfd_topology_device *top_dev;
...@@ -107,10 +107,10 @@ struct kfd_dev *kfd_device_by_id(uint32_t gpu_id) ...@@ -107,10 +107,10 @@ struct kfd_dev *kfd_device_by_id(uint32_t gpu_id)
return top_dev->gpu; return top_dev->gpu;
} }
struct kfd_dev *kfd_device_by_pci_dev(const struct pci_dev *pdev) struct kfd_node *kfd_device_by_pci_dev(const struct pci_dev *pdev)
{ {
struct kfd_topology_device *top_dev; struct kfd_topology_device *top_dev;
struct kfd_dev *device = NULL; struct kfd_node *device = NULL;
down_read(&topology_lock); down_read(&topology_lock);
...@@ -125,10 +125,10 @@ struct kfd_dev *kfd_device_by_pci_dev(const struct pci_dev *pdev) ...@@ -125,10 +125,10 @@ struct kfd_dev *kfd_device_by_pci_dev(const struct pci_dev *pdev)
return device; return device;
} }
struct kfd_dev *kfd_device_by_adev(const struct amdgpu_device *adev) struct kfd_node *kfd_device_by_adev(const struct amdgpu_device *adev)
{ {
struct kfd_topology_device *top_dev; struct kfd_topology_device *top_dev;
struct kfd_dev *device = NULL; struct kfd_node *device = NULL;
down_read(&topology_lock); down_read(&topology_lock);
...@@ -526,7 +526,7 @@ static ssize_t node_show(struct kobject *kobj, struct attribute *attr, ...@@ -526,7 +526,7 @@ static ssize_t node_show(struct kobject *kobj, struct attribute *attr,
if (dev->gpu) { if (dev->gpu) {
log_max_watch_addr = log_max_watch_addr =
__ilog2_u32(dev->gpu->device_info.num_of_watch_points); __ilog2_u32(dev->gpu->kfd->device_info.num_of_watch_points);
if (log_max_watch_addr) { if (log_max_watch_addr) {
dev->node_props.capability |= dev->node_props.capability |=
...@@ -548,11 +548,11 @@ static ssize_t node_show(struct kobject *kobj, struct attribute *attr, ...@@ -548,11 +548,11 @@ static ssize_t node_show(struct kobject *kobj, struct attribute *attr,
sysfs_show_64bit_prop(buffer, offs, "local_mem_size", 0ULL); sysfs_show_64bit_prop(buffer, offs, "local_mem_size", 0ULL);
sysfs_show_32bit_prop(buffer, offs, "fw_version", sysfs_show_32bit_prop(buffer, offs, "fw_version",
dev->gpu->mec_fw_version); dev->gpu->kfd->mec_fw_version);
sysfs_show_32bit_prop(buffer, offs, "capability", sysfs_show_32bit_prop(buffer, offs, "capability",
dev->node_props.capability); dev->node_props.capability);
sysfs_show_32bit_prop(buffer, offs, "sdma_fw_version", sysfs_show_32bit_prop(buffer, offs, "sdma_fw_version",
dev->gpu->sdma_fw_version); dev->gpu->kfd->sdma_fw_version);
sysfs_show_64bit_prop(buffer, offs, "unique_id", sysfs_show_64bit_prop(buffer, offs, "unique_id",
dev->gpu->adev->unique_id); dev->gpu->adev->unique_id);
...@@ -1157,7 +1157,7 @@ void kfd_topology_shutdown(void) ...@@ -1157,7 +1157,7 @@ void kfd_topology_shutdown(void)
up_write(&topology_lock); up_write(&topology_lock);
} }
static uint32_t kfd_generate_gpu_id(struct kfd_dev *gpu) static uint32_t kfd_generate_gpu_id(struct kfd_node *gpu)
{ {
uint32_t hashout; uint32_t hashout;
uint32_t buf[7]; uint32_t buf[7];
...@@ -1167,8 +1167,8 @@ static uint32_t kfd_generate_gpu_id(struct kfd_dev *gpu) ...@@ -1167,8 +1167,8 @@ static uint32_t kfd_generate_gpu_id(struct kfd_dev *gpu)
if (!gpu) if (!gpu)
return 0; return 0;
local_mem_size = gpu->local_mem_info.local_mem_size_private + local_mem_size = gpu->kfd->local_mem_info.local_mem_size_private +
gpu->local_mem_info.local_mem_size_public; gpu->kfd->local_mem_info.local_mem_size_public;
buf[0] = gpu->adev->pdev->devfn; buf[0] = gpu->adev->pdev->devfn;
buf[1] = gpu->adev->pdev->subsystem_vendor | buf[1] = gpu->adev->pdev->subsystem_vendor |
(gpu->adev->pdev->subsystem_device << 16); (gpu->adev->pdev->subsystem_device << 16);
...@@ -1188,7 +1188,7 @@ static uint32_t kfd_generate_gpu_id(struct kfd_dev *gpu) ...@@ -1188,7 +1188,7 @@ static uint32_t kfd_generate_gpu_id(struct kfd_dev *gpu)
* list then return NULL. This means a new topology device has to * list then return NULL. This means a new topology device has to
* be created for this GPU. * be created for this GPU.
*/ */
static struct kfd_topology_device *kfd_assign_gpu(struct kfd_dev *gpu) static struct kfd_topology_device *kfd_assign_gpu(struct kfd_node *gpu)
{ {
struct kfd_topology_device *dev; struct kfd_topology_device *dev;
struct kfd_topology_device *out_dev = NULL; struct kfd_topology_device *out_dev = NULL;
...@@ -1201,7 +1201,7 @@ static struct kfd_topology_device *kfd_assign_gpu(struct kfd_dev *gpu) ...@@ -1201,7 +1201,7 @@ static struct kfd_topology_device *kfd_assign_gpu(struct kfd_dev *gpu)
/* Discrete GPUs need their own topology device list /* Discrete GPUs need their own topology device list
* entries. Don't assign them to CPU/APU nodes. * entries. Don't assign them to CPU/APU nodes.
*/ */
if (!gpu->use_iommu_v2 && if (!gpu->kfd->use_iommu_v2 &&
dev->node_props.cpu_cores_count) dev->node_props.cpu_cores_count)
continue; continue;
...@@ -1275,7 +1275,7 @@ static void kfd_set_iolink_no_atomics(struct kfd_topology_device *dev, ...@@ -1275,7 +1275,7 @@ static void kfd_set_iolink_no_atomics(struct kfd_topology_device *dev,
CRAT_IOLINK_FLAGS_NO_ATOMICS_64_BIT; CRAT_IOLINK_FLAGS_NO_ATOMICS_64_BIT;
/* set gpu (dev) flags. */ /* set gpu (dev) flags. */
} else { } else {
if (!dev->gpu->pci_atomic_requested || if (!dev->gpu->kfd->pci_atomic_requested ||
dev->gpu->adev->asic_type == CHIP_HAWAII) dev->gpu->adev->asic_type == CHIP_HAWAII)
link->flags |= CRAT_IOLINK_FLAGS_NO_ATOMICS_32_BIT | link->flags |= CRAT_IOLINK_FLAGS_NO_ATOMICS_32_BIT |
CRAT_IOLINK_FLAGS_NO_ATOMICS_64_BIT; CRAT_IOLINK_FLAGS_NO_ATOMICS_64_BIT;
...@@ -1569,8 +1569,8 @@ static int kfd_dev_create_p2p_links(void) ...@@ -1569,8 +1569,8 @@ static int kfd_dev_create_p2p_links(void)
if (dev == new_dev) if (dev == new_dev)
break; break;
if (!dev->gpu || !dev->gpu->adev || if (!dev->gpu || !dev->gpu->adev ||
(dev->gpu->hive_id && (dev->gpu->kfd->hive_id &&
dev->gpu->hive_id == new_dev->gpu->hive_id)) dev->gpu->kfd->hive_id == new_dev->gpu->kfd->hive_id))
goto next; goto next;
/* check if node(s) is/are peer accessible in one direction or bi-direction */ /* check if node(s) is/are peer accessible in one direction or bi-direction */
...@@ -1590,7 +1590,6 @@ static int kfd_dev_create_p2p_links(void) ...@@ -1590,7 +1590,6 @@ static int kfd_dev_create_p2p_links(void)
return ret; return ret;
} }
/* Helper function. See kfd_fill_gpu_cache_info for parameter description */ /* Helper function. See kfd_fill_gpu_cache_info for parameter description */
static int fill_in_l1_pcache(struct kfd_cache_properties **props_ext, static int fill_in_l1_pcache(struct kfd_cache_properties **props_ext,
struct kfd_gpu_cache_info *pcache_info, struct kfd_gpu_cache_info *pcache_info,
...@@ -1723,7 +1722,7 @@ static int fill_in_l2_l3_pcache(struct kfd_cache_properties **props_ext, ...@@ -1723,7 +1722,7 @@ static int fill_in_l2_l3_pcache(struct kfd_cache_properties **props_ext,
/* kfd_fill_cache_non_crat_info - Fill GPU cache info using kfd_gpu_cache_info /* kfd_fill_cache_non_crat_info - Fill GPU cache info using kfd_gpu_cache_info
* tables * tables
*/ */
static void kfd_fill_cache_non_crat_info(struct kfd_topology_device *dev, struct kfd_dev *kdev) static void kfd_fill_cache_non_crat_info(struct kfd_topology_device *dev, struct kfd_node *kdev)
{ {
struct kfd_gpu_cache_info *pcache_info = NULL; struct kfd_gpu_cache_info *pcache_info = NULL;
int i, j, k; int i, j, k;
...@@ -1805,7 +1804,7 @@ static void kfd_fill_cache_non_crat_info(struct kfd_topology_device *dev, struct ...@@ -1805,7 +1804,7 @@ static void kfd_fill_cache_non_crat_info(struct kfd_topology_device *dev, struct
pr_debug("Added [%d] GPU cache entries\n", num_of_entries); pr_debug("Added [%d] GPU cache entries\n", num_of_entries);
} }
static int kfd_topology_add_device_locked(struct kfd_dev *gpu, uint32_t gpu_id, static int kfd_topology_add_device_locked(struct kfd_node *gpu, uint32_t gpu_id,
struct kfd_topology_device **dev) struct kfd_topology_device **dev)
{ {
int proximity_domain = ++topology_crat_proximity_domain; int proximity_domain = ++topology_crat_proximity_domain;
...@@ -1865,7 +1864,7 @@ static int kfd_topology_add_device_locked(struct kfd_dev *gpu, uint32_t gpu_id, ...@@ -1865,7 +1864,7 @@ static int kfd_topology_add_device_locked(struct kfd_dev *gpu, uint32_t gpu_id,
return res; return res;
} }
int kfd_topology_add_device(struct kfd_dev *gpu) int kfd_topology_add_device(struct kfd_node *gpu)
{ {
uint32_t gpu_id; uint32_t gpu_id;
struct kfd_topology_device *dev; struct kfd_topology_device *dev;
...@@ -1916,7 +1915,8 @@ int kfd_topology_add_device(struct kfd_dev *gpu) ...@@ -1916,7 +1915,8 @@ int kfd_topology_add_device(struct kfd_dev *gpu)
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;
dev->node_props.gfx_target_version = gpu->device_info.gfx_target_version; dev->node_props.gfx_target_version =
gpu->kfd->device_info.gfx_target_version;
dev->node_props.vendor_id = gpu->adev->pdev->vendor; dev->node_props.vendor_id = gpu->adev->pdev->vendor;
dev->node_props.device_id = gpu->adev->pdev->device; dev->node_props.device_id = gpu->adev->pdev->device;
dev->node_props.capability |= dev->node_props.capability |=
...@@ -1929,15 +1929,15 @@ int kfd_topology_add_device(struct kfd_dev *gpu) ...@@ -1929,15 +1929,15 @@ int kfd_topology_add_device(struct kfd_dev *gpu)
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 =
gpu->shared_resources.drm_render_minor; gpu->kfd->shared_resources.drm_render_minor;
dev->node_props.hive_id = gpu->hive_id; dev->node_props.hive_id = gpu->kfd->hive_id;
dev->node_props.num_sdma_engines = kfd_get_num_sdma_engines(gpu); dev->node_props.num_sdma_engines = kfd_get_num_sdma_engines(gpu);
dev->node_props.num_sdma_xgmi_engines = dev->node_props.num_sdma_xgmi_engines =
kfd_get_num_xgmi_sdma_engines(gpu); kfd_get_num_xgmi_sdma_engines(gpu);
dev->node_props.num_sdma_queues_per_engine = dev->node_props.num_sdma_queues_per_engine =
gpu->device_info.num_sdma_queues_per_engine - gpu->kfd->device_info.num_sdma_queues_per_engine -
gpu->device_info.num_reserved_sdma_queues_per_engine; gpu->kfd->device_info.num_reserved_sdma_queues_per_engine;
dev->node_props.num_gws = (dev->gpu->gws && dev->node_props.num_gws = (dev->gpu->gws &&
dev->gpu->dqm->sched_policy != KFD_SCHED_POLICY_NO_HWS) ? dev->gpu->dqm->sched_policy != KFD_SCHED_POLICY_NO_HWS) ?
dev->gpu->adev->gds.gws_size : 0; dev->gpu->adev->gds.gws_size : 0;
...@@ -1979,7 +1979,7 @@ int kfd_topology_add_device(struct kfd_dev *gpu) ...@@ -1979,7 +1979,7 @@ int kfd_topology_add_device(struct kfd_dev *gpu)
* Overwrite ATS capability according to needs_iommu_device to fix * Overwrite ATS capability according to needs_iommu_device to fix
* potential missing corresponding bit in CRAT of BIOS. * potential missing corresponding bit in CRAT of BIOS.
*/ */
if (dev->gpu->use_iommu_v2) if (dev->gpu->kfd->use_iommu_v2)
dev->node_props.capability |= HSA_CAP_ATS_PRESENT; dev->node_props.capability |= HSA_CAP_ATS_PRESENT;
else else
dev->node_props.capability &= ~HSA_CAP_ATS_PRESENT; dev->node_props.capability &= ~HSA_CAP_ATS_PRESENT;
...@@ -2079,7 +2079,7 @@ static void kfd_topology_update_io_links(int proximity_domain) ...@@ -2079,7 +2079,7 @@ static void kfd_topology_update_io_links(int proximity_domain)
} }
} }
int kfd_topology_remove_device(struct kfd_dev *gpu) int kfd_topology_remove_device(struct kfd_node *gpu)
{ {
struct kfd_topology_device *dev, *tmp; struct kfd_topology_device *dev, *tmp;
uint32_t gpu_id; uint32_t gpu_id;
...@@ -2119,7 +2119,7 @@ int kfd_topology_remove_device(struct kfd_dev *gpu) ...@@ -2119,7 +2119,7 @@ int kfd_topology_remove_device(struct kfd_dev *gpu)
* Return - 0: On success (@kdev will be NULL for non GPU nodes) * Return - 0: On success (@kdev will be NULL for non GPU nodes)
* -1: If end of list * -1: If end of list
*/ */
int kfd_topology_enum_kfd_devices(uint8_t idx, struct kfd_dev **kdev) int kfd_topology_enum_kfd_devices(uint8_t idx, struct kfd_node **kdev)
{ {
struct kfd_topology_device *top_dev; struct kfd_topology_device *top_dev;
......
...@@ -75,7 +75,7 @@ struct kfd_mem_properties { ...@@ -75,7 +75,7 @@ struct kfd_mem_properties {
uint32_t flags; uint32_t flags;
uint32_t width; uint32_t width;
uint32_t mem_clk_max; uint32_t mem_clk_max;
struct kfd_dev *gpu; struct kfd_node *gpu;
struct kobject *kobj; struct kobject *kobj;
struct attribute attr; struct attribute attr;
}; };
...@@ -93,7 +93,7 @@ struct kfd_cache_properties { ...@@ -93,7 +93,7 @@ struct kfd_cache_properties {
uint32_t cache_latency; uint32_t cache_latency;
uint32_t cache_type; uint32_t cache_type;
uint8_t sibling_map[CACHE_SIBLINGMAP_SIZE]; uint8_t sibling_map[CACHE_SIBLINGMAP_SIZE];
struct kfd_dev *gpu; struct kfd_node *gpu;
struct kobject *kobj; struct kobject *kobj;
struct attribute attr; struct attribute attr;
uint32_t sibling_map_size; uint32_t sibling_map_size;
...@@ -113,7 +113,7 @@ struct kfd_iolink_properties { ...@@ -113,7 +113,7 @@ struct kfd_iolink_properties {
uint32_t max_bandwidth; uint32_t max_bandwidth;
uint32_t rec_transfer_size; uint32_t rec_transfer_size;
uint32_t flags; uint32_t flags;
struct kfd_dev *gpu; struct kfd_node *gpu;
struct kobject *kobj; struct kobject *kobj;
struct attribute attr; struct attribute attr;
}; };
...@@ -135,7 +135,7 @@ struct kfd_topology_device { ...@@ -135,7 +135,7 @@ struct kfd_topology_device {
struct list_head io_link_props; struct list_head io_link_props;
struct list_head p2p_link_props; struct list_head p2p_link_props;
struct list_head perf_props; struct list_head perf_props;
struct kfd_dev *gpu; struct kfd_node *gpu;
struct kobject *kobj_node; struct kobject *kobj_node;
struct kobject *kobj_mem; struct kobject *kobj_mem;
struct kobject *kobj_cache; struct kobject *kobj_cache;
......
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