aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>2018-02-06 20:32:42 -0500
committerOded Gabbay <oded.gabbay@gmail.com>2018-02-06 20:32:42 -0500
commit4252bf686622f6c71958c4fabbcb6a64deba1cf7 (patch)
tree3ba774e973f3d8fe22475280f33a1876d55ff290
parent64d1c3a43a6fb5cef32a085bc17cbbe31945a651 (diff)
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: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com> Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com> Acked-by: Oded Gabbay <oded.gabbay@gmail.com> Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index 47d493ea8e4f..1a28dc2c661e 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -118,9 +118,8 @@ static int allocate_vmid(struct device_queue_manager *dqm,
118 if (dqm->vmid_bitmap == 0) 118 if (dqm->vmid_bitmap == 0)
119 return -ENOMEM; 119 return -ENOMEM;
120 120
121 bit = find_first_bit((unsigned long *)&dqm->vmid_bitmap, 121 bit = ffs(dqm->vmid_bitmap) - 1;
122 dqm->dev->vm_info.vmid_num_kfd); 122 dqm->vmid_bitmap &= ~(1 << bit);
123 clear_bit(bit, (unsigned long *)&dqm->vmid_bitmap);
124 123
125 allocated_vmid = bit + dqm->dev->vm_info.first_vmid_kfd; 124 allocated_vmid = bit + dqm->dev->vm_info.first_vmid_kfd;
126 pr_debug("vmid allocation %d\n", allocated_vmid); 125 pr_debug("vmid allocation %d\n", allocated_vmid);
@@ -142,7 +141,7 @@ static void deallocate_vmid(struct device_queue_manager *dqm,
142 /* Release the vmid mapping */ 141 /* Release the vmid mapping */
143 set_pasid_vmid_mapping(dqm, 0, qpd->vmid); 142 set_pasid_vmid_mapping(dqm, 0, qpd->vmid);
144 143
145 set_bit(bit, (unsigned long *)&dqm->vmid_bitmap); 144 dqm->vmid_bitmap |= (1 << bit);
146 qpd->vmid = 0; 145 qpd->vmid = 0;
147 q->properties.vmid = 0; 146 q->properties.vmid = 0;
148} 147}
@@ -223,12 +222,8 @@ static int allocate_hqd(struct device_queue_manager *dqm, struct queue *q)
223 continue; 222 continue;
224 223
225 if (dqm->allocated_queues[pipe] != 0) { 224 if (dqm->allocated_queues[pipe] != 0) {
226 bit = find_first_bit( 225 bit = ffs(dqm->allocated_queues[pipe]) - 1;
227 (unsigned long *)&dqm->allocated_queues[pipe], 226 dqm->allocated_queues[pipe] &= ~(1 << bit);
228 get_queues_per_pipe(dqm));
229
230 clear_bit(bit,
231 (unsigned long *)&dqm->allocated_queues[pipe]);
232 q->pipe = pipe; 227 q->pipe = pipe;
233 q->queue = bit; 228 q->queue = bit;
234 set = true; 229 set = true;
@@ -249,7 +244,7 @@ static int allocate_hqd(struct device_queue_manager *dqm, struct queue *q)
249static inline void deallocate_hqd(struct device_queue_manager *dqm, 244static inline void deallocate_hqd(struct device_queue_manager *dqm,
250 struct queue *q) 245 struct queue *q)
251{ 246{
252 set_bit(q->queue, (unsigned long *)&dqm->allocated_queues[q->pipe]); 247 dqm->allocated_queues[q->pipe] |= (1 << q->queue);
253} 248}
254 249
255static int create_compute_queue_nocpsch(struct device_queue_manager *dqm, 250static 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 if (dqm->sdma_bitmap == 0) 584 if (dqm->sdma_bitmap == 0)
590 return -ENOMEM; 585 return -ENOMEM;
591 586
592 bit = find_first_bit((unsigned long *)&dqm->sdma_bitmap, 587 bit = ffs(dqm->sdma_bitmap) - 1;
593 CIK_SDMA_QUEUES); 588 dqm->sdma_bitmap &= ~(1 << bit);
594
595 clear_bit(bit, (unsigned long *)&dqm->sdma_bitmap);
596 *sdma_queue_id = bit; 589 *sdma_queue_id = bit;
597 590
598 return 0; 591 return 0;
@@ -603,7 +596,7 @@ static void deallocate_sdma_queue(struct device_queue_manager *dqm,
603{ 596{
604 if (sdma_queue_id >= CIK_SDMA_QUEUES) 597 if (sdma_queue_id >= CIK_SDMA_QUEUES)
605 return; 598 return;
606 set_bit(sdma_queue_id, (unsigned long *)&dqm->sdma_bitmap); 599 dqm->sdma_bitmap |= (1 << sdma_queue_id);
607} 600}
608 601
609static int create_sdma_queue_nocpsch(struct device_queue_manager *dqm, 602static int create_sdma_queue_nocpsch(struct device_queue_manager *dqm,