Commit 44008d7a authored by Yong Zhao's avatar Yong Zhao Committed by Oded Gabbay

drm/amdkfd: Use VMID bitmap from KGD v2

The hard-coded values related to VMID were removed in KFD, as those
values can be calculated in the KFD initialization function.

v2: remove unnecessary local variable
Signed-off-by: default avatarYong Zhao <yong.zhao@amd.com>
Signed-off-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: default avatarOded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: default avatarOded Gabbay <oded.gabbay@gmail.com>
parent b90e3fbe
...@@ -769,13 +769,8 @@ int dbgdev_wave_reset_wavefronts(struct kfd_dev *dev, struct kfd_process *p) ...@@ -769,13 +769,8 @@ int dbgdev_wave_reset_wavefronts(struct kfd_dev *dev, struct kfd_process *p)
union GRBM_GFX_INDEX_BITS reg_gfx_index; union GRBM_GFX_INDEX_BITS reg_gfx_index;
struct kfd_process_device *pdd; struct kfd_process_device *pdd;
struct dbg_wave_control_info wac_info; struct dbg_wave_control_info wac_info;
int temp; int first_vmid_to_scan = dev->vm_info.first_vmid_kfd;
int first_vmid_to_scan = 8; int last_vmid_to_scan = dev->vm_info.last_vmid_kfd;
int last_vmid_to_scan = 15;
first_vmid_to_scan = ffs(dev->shared_resources.compute_vmid_bitmap) - 1;
temp = dev->shared_resources.compute_vmid_bitmap >> first_vmid_to_scan;
last_vmid_to_scan = first_vmid_to_scan + ffz(temp);
reg_sq_cmd.u32All = 0; reg_sq_cmd.u32All = 0;
status = 0; status = 0;
......
...@@ -219,6 +219,11 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd, ...@@ -219,6 +219,11 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
kfd->shared_resources = *gpu_resources; kfd->shared_resources = *gpu_resources;
kfd->vm_info.first_vmid_kfd = ffs(gpu_resources->compute_vmid_bitmap)-1;
kfd->vm_info.last_vmid_kfd = fls(gpu_resources->compute_vmid_bitmap)-1;
kfd->vm_info.vmid_num_kfd = kfd->vm_info.last_vmid_kfd
- kfd->vm_info.first_vmid_kfd + 1;
/* calculate max size of mqds needed for queues */ /* calculate max size of mqds needed for queues */
size = max_num_of_queues_per_device * size = max_num_of_queues_per_device *
kfd->device_info->mqd_size_aligned; kfd->device_info->mqd_size_aligned;
......
...@@ -113,11 +113,11 @@ static int allocate_vmid(struct device_queue_manager *dqm, ...@@ -113,11 +113,11 @@ static int allocate_vmid(struct device_queue_manager *dqm,
if (dqm->vmid_bitmap == 0) if (dqm->vmid_bitmap == 0)
return -ENOMEM; return -ENOMEM;
bit = find_first_bit((unsigned long *)&dqm->vmid_bitmap, CIK_VMID_NUM); bit = find_first_bit((unsigned long *)&dqm->vmid_bitmap,
dqm->dev->vm_info.vmid_num_kfd);
clear_bit(bit, (unsigned long *)&dqm->vmid_bitmap); clear_bit(bit, (unsigned long *)&dqm->vmid_bitmap);
/* Kaveri kfd vmid's starts from vmid 8 */ allocated_vmid = bit + dqm->dev->vm_info.first_vmid_kfd;
allocated_vmid = bit + KFD_VMID_START_OFFSET;
pr_debug("vmid allocation %d\n", allocated_vmid); pr_debug("vmid allocation %d\n", allocated_vmid);
qpd->vmid = allocated_vmid; qpd->vmid = allocated_vmid;
q->properties.vmid = allocated_vmid; q->properties.vmid = allocated_vmid;
...@@ -132,7 +132,7 @@ static void deallocate_vmid(struct device_queue_manager *dqm, ...@@ -132,7 +132,7 @@ static void deallocate_vmid(struct device_queue_manager *dqm,
struct qcm_process_device *qpd, struct qcm_process_device *qpd,
struct queue *q) struct queue *q)
{ {
int bit = qpd->vmid - KFD_VMID_START_OFFSET; int bit = qpd->vmid - dqm->dev->vm_info.first_vmid_kfd;
/* Release the vmid mapping */ /* Release the vmid mapping */
set_pasid_vmid_mapping(dqm, 0, qpd->vmid); set_pasid_vmid_mapping(dqm, 0, qpd->vmid);
...@@ -507,7 +507,7 @@ static int initialize_nocpsch(struct device_queue_manager *dqm) ...@@ -507,7 +507,7 @@ static int initialize_nocpsch(struct device_queue_manager *dqm)
dqm->allocated_queues[pipe] |= 1 << queue; dqm->allocated_queues[pipe] |= 1 << queue;
} }
dqm->vmid_bitmap = (1 << VMID_PER_DEVICE) - 1; dqm->vmid_bitmap = (1 << dqm->dev->vm_info.vmid_num_kfd) - 1;
dqm->sdma_bitmap = (1 << CIK_SDMA_QUEUES) - 1; dqm->sdma_bitmap = (1 << CIK_SDMA_QUEUES) - 1;
return 0; return 0;
...@@ -613,8 +613,7 @@ static int set_sched_resources(struct device_queue_manager *dqm) ...@@ -613,8 +613,7 @@ static int set_sched_resources(struct device_queue_manager *dqm)
int i, mec; int i, mec;
struct scheduling_resources res; struct scheduling_resources res;
res.vmid_mask = (1 << VMID_PER_DEVICE) - 1; res.vmid_mask = dqm->dev->shared_resources.compute_vmid_bitmap;
res.vmid_mask <<= KFD_VMID_START_OFFSET;
res.queue_mask = 0; res.queue_mask = 0;
for (i = 0; i < KGD_MAX_QUEUES; ++i) { for (i = 0; i < KGD_MAX_QUEUES; ++i) {
......
...@@ -32,10 +32,6 @@ ...@@ -32,10 +32,6 @@
#define KFD_UNMAP_LATENCY_MS (4000) #define KFD_UNMAP_LATENCY_MS (4000)
#define QUEUE_PREEMPT_DEFAULT_TIMEOUT_MS (2 * KFD_UNMAP_LATENCY_MS + 1000) #define QUEUE_PREEMPT_DEFAULT_TIMEOUT_MS (2 * KFD_UNMAP_LATENCY_MS + 1000)
#define CIK_VMID_NUM (8)
#define KFD_VMID_START_OFFSET (8)
#define VMID_PER_DEVICE CIK_VMID_NUM
#define KFD_DQM_FIRST_PIPE (0)
#define CIK_SDMA_QUEUES (4) #define CIK_SDMA_QUEUES (4)
#define CIK_SDMA_QUEUES_PER_ENGINE (2) #define CIK_SDMA_QUEUES_PER_ENGINE (2)
#define CIK_SDMA_ENGINE_NUM (2) #define CIK_SDMA_ENGINE_NUM (2)
......
...@@ -141,6 +141,12 @@ struct kfd_mem_obj { ...@@ -141,6 +141,12 @@ struct kfd_mem_obj {
uint32_t *cpu_ptr; uint32_t *cpu_ptr;
}; };
struct kfd_vmid_info {
uint32_t first_vmid_kfd;
uint32_t last_vmid_kfd;
uint32_t vmid_num_kfd;
};
struct kfd_dev { struct kfd_dev {
struct kgd_dev *kgd; struct kgd_dev *kgd;
...@@ -162,6 +168,7 @@ struct kfd_dev { ...@@ -162,6 +168,7 @@ struct kfd_dev {
*/ */
struct kgd2kfd_shared_resources shared_resources; struct kgd2kfd_shared_resources shared_resources;
struct kfd_vmid_info vm_info;
const struct kfd2kgd_calls *kfd2kgd; const struct kfd2kgd_calls *kfd2kgd;
struct mutex doorbell_mutex; struct mutex doorbell_mutex;
......
...@@ -187,7 +187,7 @@ int pqm_create_queue(struct process_queue_manager *pqm, ...@@ -187,7 +187,7 @@ int pqm_create_queue(struct process_queue_manager *pqm,
case KFD_QUEUE_TYPE_COMPUTE: case KFD_QUEUE_TYPE_COMPUTE:
/* check if there is over subscription */ /* check if there is over subscription */
if ((sched_policy == KFD_SCHED_POLICY_HWS_NO_OVERSUBSCRIPTION) && if ((sched_policy == KFD_SCHED_POLICY_HWS_NO_OVERSUBSCRIPTION) &&
((dev->dqm->processes_count >= VMID_PER_DEVICE) || ((dev->dqm->processes_count >= dev->vm_info.vmid_num_kfd) ||
(dev->dqm->queue_count >= get_queues_num(dev->dqm)))) { (dev->dqm->queue_count >= get_queues_num(dev->dqm)))) {
pr_err("Over-subscription is not allowed in radeon_kfd.sched_policy == 1\n"); pr_err("Over-subscription is not allowed in radeon_kfd.sched_policy == 1\n");
retval = -EPERM; retval = -EPERM;
......
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