Commit 4252bf68 authored by Harish Kasiviswanathan's avatar Harish Kasiviswanathan Committed by Oded Gabbay

drm/amdkfd: Remove unaligned memory access

Unaligned atomic operations can cause problems on some CPU
architectures. Use simpler bitmask operations instead. Atomic bit
manipulations are not necessary since dqm->lock is held during these
operations.
Signed-off-by: default avatarHarish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
Signed-off-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Acked-by: default avatarOded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: default avatarOded Gabbay <oded.gabbay@gmail.com>
parent 64d1c3a4
...@@ -118,9 +118,8 @@ static int allocate_vmid(struct device_queue_manager *dqm, ...@@ -118,9 +118,8 @@ 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, bit = ffs(dqm->vmid_bitmap) - 1;
dqm->dev->vm_info.vmid_num_kfd); dqm->vmid_bitmap &= ~(1 << bit);
clear_bit(bit, (unsigned long *)&dqm->vmid_bitmap);
allocated_vmid = bit + dqm->dev->vm_info.first_vmid_kfd; allocated_vmid = bit + dqm->dev->vm_info.first_vmid_kfd;
pr_debug("vmid allocation %d\n", allocated_vmid); pr_debug("vmid allocation %d\n", allocated_vmid);
...@@ -142,7 +141,7 @@ static void deallocate_vmid(struct device_queue_manager *dqm, ...@@ -142,7 +141,7 @@ static void deallocate_vmid(struct device_queue_manager *dqm,
/* Release the vmid mapping */ /* Release the vmid mapping */
set_pasid_vmid_mapping(dqm, 0, qpd->vmid); set_pasid_vmid_mapping(dqm, 0, qpd->vmid);
set_bit(bit, (unsigned long *)&dqm->vmid_bitmap); dqm->vmid_bitmap |= (1 << bit);
qpd->vmid = 0; qpd->vmid = 0;
q->properties.vmid = 0; q->properties.vmid = 0;
} }
...@@ -223,12 +222,8 @@ static int allocate_hqd(struct device_queue_manager *dqm, struct queue *q) ...@@ -223,12 +222,8 @@ static int allocate_hqd(struct device_queue_manager *dqm, struct queue *q)
continue; continue;
if (dqm->allocated_queues[pipe] != 0) { if (dqm->allocated_queues[pipe] != 0) {
bit = find_first_bit( bit = ffs(dqm->allocated_queues[pipe]) - 1;
(unsigned long *)&dqm->allocated_queues[pipe], dqm->allocated_queues[pipe] &= ~(1 << bit);
get_queues_per_pipe(dqm));
clear_bit(bit,
(unsigned long *)&dqm->allocated_queues[pipe]);
q->pipe = pipe; q->pipe = pipe;
q->queue = bit; q->queue = bit;
set = true; set = true;
...@@ -249,7 +244,7 @@ static int allocate_hqd(struct device_queue_manager *dqm, struct queue *q) ...@@ -249,7 +244,7 @@ static int allocate_hqd(struct device_queue_manager *dqm, struct queue *q)
static inline void deallocate_hqd(struct device_queue_manager *dqm, static inline void deallocate_hqd(struct device_queue_manager *dqm,
struct queue *q) struct queue *q)
{ {
set_bit(q->queue, (unsigned long *)&dqm->allocated_queues[q->pipe]); dqm->allocated_queues[q->pipe] |= (1 << q->queue);
} }
static int create_compute_queue_nocpsch(struct device_queue_manager *dqm, static int create_compute_queue_nocpsch(struct device_queue_manager *dqm,
...@@ -589,10 +584,8 @@ static int allocate_sdma_queue(struct device_queue_manager *dqm, ...@@ -589,10 +584,8 @@ static int allocate_sdma_queue(struct device_queue_manager *dqm,
if (dqm->sdma_bitmap == 0) if (dqm->sdma_bitmap == 0)
return -ENOMEM; return -ENOMEM;
bit = find_first_bit((unsigned long *)&dqm->sdma_bitmap, bit = ffs(dqm->sdma_bitmap) - 1;
CIK_SDMA_QUEUES); dqm->sdma_bitmap &= ~(1 << bit);
clear_bit(bit, (unsigned long *)&dqm->sdma_bitmap);
*sdma_queue_id = bit; *sdma_queue_id = bit;
return 0; return 0;
...@@ -603,7 +596,7 @@ static void deallocate_sdma_queue(struct device_queue_manager *dqm, ...@@ -603,7 +596,7 @@ static void deallocate_sdma_queue(struct device_queue_manager *dqm,
{ {
if (sdma_queue_id >= CIK_SDMA_QUEUES) if (sdma_queue_id >= CIK_SDMA_QUEUES)
return; return;
set_bit(sdma_queue_id, (unsigned long *)&dqm->sdma_bitmap); dqm->sdma_bitmap |= (1 << sdma_queue_id);
} }
static int create_sdma_queue_nocpsch(struct device_queue_manager *dqm, static int create_sdma_queue_nocpsch(struct device_queue_manager *dqm,
......
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