History

Merge tag 'drm-amdkfd-next-2016-09-19' of git://people.freedesktop.org/~gabbayo/linux into drm-next

This is amdkfd's pull request for kernel 4.9. It contains a fix to a possible infinite loop bug and a couple of other minor "cleaning" patches. * tag 'drm-amdkfd-next-2016-09-19' of git://people.freedesktop.org/~gabbayo/linux: drm/amdkfd: Pass 'struct queue_propertices' by reference drm/amdkfd: Unify multiple calls to pr_debug() into one drm/amdkfd: Fix possible infinite loop drm/amdkfd: Reuse function to find a process through pasid drm/amdkfd: Add some missing memset zero'ing in queue init func drm/amdkfd: Tidy up kfd_generate_gpu_id() uint64_t bitshift unpack

Dave Airlie committed 10 years ago

Commit 196ebdc2 parents 52f13a0 e88a6149 files · +65 −67Browse files

Unified · Split

9 files
  1. drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c +9 −8
  2. drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c +9 −8
  3. drivers/gpu/drm/amd/amdkfd/kfd_doorbell.c +9 −7
  4. drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c +4 −1
  5. drivers/gpu/drm/amd/amdkfd/kfd_priv.h +1 −1
  6. drivers/gpu/drm/amd/amdkfd/kfd_process.c +25 −36
  7. drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +1 −1
  8. drivers/gpu/drm/amd/amdkfd/kfd_queue.c +2 −2
  9. drivers/gpu/drm/amd/amdkfd/kfd_topology.c +5 −3
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c+9−8
@@ -103,11 +103,11 @@ static bool kgd_hqd_is_occupied(struct kgd_dev *kgd, uint64_t queue_address, · 102 unmodified lines
103103 uint32_t pipe_id, uint32_t queue_id);
104104
105105 static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t reset_type,
106− unsigned int timeout, uint32_t pipe_id,
106+ unsigned int utimeout, uint32_t pipe_id,
107107 uint32_t queue_id);
108108 static bool kgd_hqd_sdma_is_occupied(struct kgd_dev *kgd, void *mqd);
109109 static int kgd_hqd_sdma_destroy(struct kgd_dev *kgd, void *mqd,
110− unsigned int timeout);
110+ unsigned int utimeout);
111111 static int kgd_address_watch_disable(struct kgd_dev *kgd);
112112 static int kgd_address_watch_execute(struct kgd_dev *kgd,
113113 unsigned int watch_point_id,
@@ -437,11 +437,12 @@ static bool kgd_hqd_sdma_is_occupied(struct kgd_dev *kgd, void *mqd) · 323 unmodified lines
437437 }
438438
439439 static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t reset_type,
440− unsigned int timeout, uint32_t pipe_id,
440+ unsigned int utimeout, uint32_t pipe_id,
441441 uint32_t queue_id)
442442 {
443443 struct amdgpu_device *adev = get_amdgpu_device(kgd);
444444 uint32_t temp;
445+ int timeout = utimeout;
445446
446447 acquire_queue(kgd, pipe_id, queue_id);
447448 WREG32(mmCP_HQD_PQ_DOORBELL_CONTROL, 0);
@@ -452,9 +453,8 @@ static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t reset_type, · 4 unmodified lines
452453 temp = RREG32(mmCP_HQD_ACTIVE);
453454 if (temp & CP_HQD_ACTIVE__ACTIVE_MASK)
454455 break;
455− if (timeout == 0) {
456− pr_err("kfd: cp queue preemption time out (%dms)\n",
457− temp);
456+ if (timeout <= 0) {
457+ pr_err("kfd: cp queue preemption time out.\n");
458458 release_queue(kgd);
459459 return -ETIME;
460460 }
@@ -467,12 +467,13 @@ static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t reset_type, · 6 unmodified lines
467467 }
468468
469469 static int kgd_hqd_sdma_destroy(struct kgd_dev *kgd, void *mqd,
470− unsigned int timeout)
470+ unsigned int utimeout)
471471 {
472472 struct amdgpu_device *adev = get_amdgpu_device(kgd);
473473 struct cik_sdma_rlc_registers *m;
474474 uint32_t sdma_base_addr;
475475 uint32_t temp;
476+ int timeout = utimeout;
476477
477478 m = get_sdma_mqd(mqd);
478479 sdma_base_addr = get_sdma_base_addr(m);
@@ -485,7 +486,7 @@ static int kgd_hqd_sdma_destroy(struct kgd_dev *kgd, void *mqd, · 6 unmodified lines
485486 temp = RREG32(sdma_base_addr + mmSDMA0_RLC0_CONTEXT_STATUS);
486487 if (temp & SDMA0_STATUS_REG__RB_CMD_IDLE__SHIFT)
487488 break;
488− if (timeout == 0)
489+ if (timeout <= 0)
489490 return -ETIME;
490491 msleep(20);
491492 timeout -= 20;
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c+9−8
@@ -62,10 +62,10 @@ static bool kgd_hqd_is_occupied(struct kgd_dev *kgd, uint64_t queue_address, · 61 unmodified lines
6262 uint32_t pipe_id, uint32_t queue_id);
6363 static bool kgd_hqd_sdma_is_occupied(struct kgd_dev *kgd, void *mqd);
6464 static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t reset_type,
65− unsigned int timeout, uint32_t pipe_id,
65+ unsigned int utimeout, uint32_t pipe_id,
6666 uint32_t queue_id);
6767 static int kgd_hqd_sdma_destroy(struct kgd_dev *kgd, void *mqd,
68− unsigned int timeout);
68+ unsigned int utimeout);
6969 static void write_vmid_invalidate_request(struct kgd_dev *kgd, uint8_t vmid);
7070 static int kgd_address_watch_disable(struct kgd_dev *kgd);
7171 static int kgd_address_watch_execute(struct kgd_dev *kgd,
@@ -349,11 +349,12 @@ static bool kgd_hqd_sdma_is_occupied(struct kgd_dev *kgd, void *mqd) · 277 unmodified lines
349349 }
350350
351351 static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t reset_type,
352− unsigned int timeout, uint32_t pipe_id,
352+ unsigned int utimeout, uint32_t pipe_id,
353353 uint32_t queue_id)
354354 {
355355 struct amdgpu_device *adev = get_amdgpu_device(kgd);
356356 uint32_t temp;
357+ int timeout = utimeout;
357358
358359 acquire_queue(kgd, pipe_id, queue_id);
359360
@@ -363,9 +364,8 @@ static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t reset_type, · 3 unmodified lines
363364 temp = RREG32(mmCP_HQD_ACTIVE);
364365 if (temp & CP_HQD_ACTIVE__ACTIVE_MASK)
365366 break;
366− if (timeout == 0) {
367− pr_err("kfd: cp queue preemption time out (%dms)\n",
368− temp);
367+ if (timeout <= 0) {
368+ pr_err("kfd: cp queue preemption time out.\n");
369369 release_queue(kgd);
370370 return -ETIME;
371371 }
@@ -378,12 +378,13 @@ static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t reset_type, · 6 unmodified lines
378378 }
379379
380380 static int kgd_hqd_sdma_destroy(struct kgd_dev *kgd, void *mqd,
381− unsigned int timeout)
381+ unsigned int utimeout)
382382 {
383383 struct amdgpu_device *adev = get_amdgpu_device(kgd);
384384 struct cik_sdma_rlc_registers *m;
385385 uint32_t sdma_base_addr;
386386 uint32_t temp;
387+ int timeout = utimeout;
387388
388389 m = get_sdma_mqd(mqd);
389390 sdma_base_addr = get_sdma_base_addr(m);
@@ -396,7 +397,7 @@ static int kgd_hqd_sdma_destroy(struct kgd_dev *kgd, void *mqd, · 6 unmodified lines
396397 temp = RREG32(sdma_base_addr + mmSDMA0_RLC0_CONTEXT_STATUS);
397398 if (temp & SDMA0_STATUS_REG__RB_CMD_IDLE__SHIFT)
398399 break;
399− if (timeout == 0)
400+ if (timeout <= 0)
400401 return -ETIME;
401402 msleep(20);
402403 timeout -= 20;
drivers/gpu/drm/amd/amdkfd/kfd_doorbell.c+9−7
@@ -142,13 +142,15 @@ int kfd_doorbell_mmap(struct kfd_process *process, struct vm_area_struct *vma) · 141 unmodified lines
142142
143143 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
144144
145− pr_debug("mapping doorbell page:\n");
146− pr_debug(" target user address == 0x%08llX\n",
147− (unsigned long long) vma->vm_start);
148− pr_debug(" physical address == 0x%08llX\n", address);
149− pr_debug(" vm_flags == 0x%04lX\n", vma->vm_flags);
150− pr_debug(" size == 0x%04lX\n",
151− doorbell_process_allocation());
145+ pr_debug("kfd: mapping doorbell page in %s\n"
146+ " target user address == 0x%08llX\n"
147+ " physical address == 0x%08llX\n"
148+ " vm_flags == 0x%04lX\n"
149+ " size == 0x%04lX\n",
150+ __func__,
151+ (unsigned long long) vma->vm_start, address, vma->vm_flags,
152+ doorbell_process_allocation());
153+
152154
153155 return io_remap_pfn_range(vma,
154156 vma->vm_start,
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c+4−1
@@ -47,6 +47,9 @@ static bool initialize(struct kernel_queue *kq, struct kfd_dev *dev, · 46 unmodified lines
4747 pr_debug("amdkfd: In func %s initializing queue type %d size %d\n",
4848 __func__, KFD_QUEUE_TYPE_HIQ, queue_size);
4949
50+ memset(&prop, 0, sizeof(prop));
51+ memset(&nop, 0, sizeof(nop));
52+
5053 nop.opcode = IT_NOP;
5154 nop.type = PM4_TYPE_3;
5255 nop.u32all |= PM4_COUNT_ZERO;
@@ -121,7 +124,7 @@ static bool initialize(struct kernel_queue *kq, struct kfd_dev *dev, · 68 unmodified lines
121124 prop.eop_ring_buffer_address = kq->eop_gpu_addr;
122125 prop.eop_ring_buffer_size = PAGE_SIZE;
123126
124− if (init_queue(&kq->queue, prop) != 0)
127+ if (init_queue(&kq->queue, &prop) != 0)
125128 goto err_init_queue;
126129
127130 kq->queue->device = dev;
drivers/gpu/drm/amd/amdkfd/kfd_priv.h+1−1
@@ -619,7 +619,7 @@ int kfd_init_apertures(struct kfd_process *process); · 618 unmodified lines
619619 /* Queue Context Management */
620620 struct cik_sdma_rlc_registers *get_sdma_mqd(void *mqd);
621621
622−int init_queue(struct queue **q, struct queue_properties properties);
622+int init_queue(struct queue **q, const struct queue_properties *properties);
623623 void uninit_queue(struct queue *q);
624624 void print_queue_properties(struct queue_properties *q);
625625 void print_queue(struct queue *q);
drivers/gpu/drm/amd/amdkfd/kfd_process.c+25−36
@@ -404,58 +404,47 @@ void kfd_unbind_process_from_device(struct kfd_dev *dev, unsigned int pasid) · 403 unmodified lines
404404 {
405405 struct kfd_process *p;
406406 struct kfd_process_device *pdd;
407− int idx, i;
408407
409408 BUG_ON(dev == NULL);
410409
411− idx = srcu_read_lock(&kfd_processes_srcu);
412−
413410 /*
414411 * Look for the process that matches the pasid. If there is no such
415412 * process, we either released it in amdkfd's own notifier, or there
416413 * is a bug. Unfortunately, there is no way to tell...
417414 */
418− hash_for_each_rcu(kfd_processes_table, i, p, kfd_processes)
419− if (p->pasid == pasid) {
420−
421− srcu_read_unlock(&kfd_processes_srcu, idx);
422−
423− pr_debug("Unbinding process %d from IOMMU\n", pasid);
415+ p = kfd_lookup_process_by_pasid(pasid);
416+ if (!p)
417+ return;
424418
425− mutex_lock(&p->mutex);
426−
427− if ((dev->dbgmgr) && (dev->dbgmgr->pasid == p->pasid))
428− kfd_dbgmgr_destroy(dev->dbgmgr);
429−
430− pqm_uninit(&p->pqm);
419+ pr_debug("Unbinding process %d from IOMMU\n", pasid);
431420
432− pdd = kfd_get_process_device_data(dev, p);
421+ if ((dev->dbgmgr) && (dev->dbgmgr->pasid == p->pasid))
422+ kfd_dbgmgr_destroy(dev->dbgmgr);
433423
434− if (!pdd) {
435− mutex_unlock(&p->mutex);
436− return;
437− }
424+ pqm_uninit(&p->pqm);
438425
439− if (pdd->reset_wavefronts) {
440− dbgdev_wave_reset_wavefronts(pdd->dev, p);
441− pdd->reset_wavefronts = false;
442− }
426+ pdd = kfd_get_process_device_data(dev, p);
443427
444− /*
445− * Just mark pdd as unbound, because we still need it
446− * to call amd_iommu_unbind_pasid() in when the
447− * process exits.
448− * We don't call amd_iommu_unbind_pasid() here
449− * because the IOMMU called us.
450− */
451− pdd->bound = false;
428+ if (!pdd) {
429+ mutex_unlock(&p->mutex);
430+ return;
431+ }
452432
453− mutex_unlock(&p->mutex);
433+ if (pdd->reset_wavefronts) {
434+ dbgdev_wave_reset_wavefronts(pdd->dev, p);
435+ pdd->reset_wavefronts = false;
436+ }
454437
455− return;
456− }
438+ /*
439+ * Just mark pdd as unbound, because we still need it
440+ * to call amd_iommu_unbind_pasid() in when the
441+ * process exits.
442+ * We don't call amd_iommu_unbind_pasid() here
443+ * because the IOMMU called us.
444+ */
445+ pdd->bound = false;
457446
458− srcu_read_unlock(&kfd_processes_srcu, idx);
447+ mutex_unlock(&p->mutex);
459448 }
460449
461450 struct kfd_process_device *kfd_get_first_process_device_data(struct kfd_process *p)
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c+1−1
@@ -129,7 +129,7 @@ static int create_cp_queue(struct process_queue_manager *pqm, · 128 unmodified lines
129129 q_properties->vmid = 0;
130130 q_properties->queue_id = qid;
131131
132− retval = init_queue(q, *q_properties);
132+ retval = init_queue(q, q_properties);
133133 if (retval != 0)
134134 goto err_init_queue;
135135
drivers/gpu/drm/amd/amdkfd/kfd_queue.c+2−2
@@ -63,7 +63,7 @@ void print_queue(struct queue *q) · 62 unmodified lines
6363 pr_debug("Queue Device Address: 0x%p\n", q->device);
6464 }
6565
66−int init_queue(struct queue **q, struct queue_properties properties)
66+int init_queue(struct queue **q, const struct queue_properties *properties)
6767 {
6868 struct queue *tmp;
6969
@@ -73,7 +73,7 @@ int init_queue(struct queue **q, struct queue_properties properties) · 3 unmodified lines
7373 if (!tmp)
7474 return -ENOMEM;
7575
76− memcpy(&tmp->properties, &properties, sizeof(struct queue_properties));
76+ memcpy(&tmp->properties, properties, sizeof(struct queue_properties));
7777
7878 *q = tmp;
7979 return 0;
drivers/gpu/drm/amd/amdkfd/kfd_topology.c+5−3
@@ -1090,19 +1090,21 @@ static uint32_t kfd_generate_gpu_id(struct kfd_dev *gpu) · 1089 unmodified lines
10901090 {
10911091 uint32_t hashout;
10921092 uint32_t buf[7];
1093+ uint64_t local_mem_size;
10931094 int i;
10941095
10951096 if (!gpu)
10961097 return 0;
10971098
1099+ local_mem_size = gpu->kfd2kgd->get_vmem_size(gpu->kgd);
1100+
10981101 buf[0] = gpu->pdev->devfn;
10991102 buf[1] = gpu->pdev->subsystem_vendor;
11001103 buf[2] = gpu->pdev->subsystem_device;
11011104 buf[3] = gpu->pdev->device;
11021105 buf[4] = gpu->pdev->bus->number;
1103− buf[5] = (uint32_t)(gpu->kfd2kgd->get_vmem_size(gpu->kgd)
1104− & 0xffffffff);
1105− buf[6] = (uint32_t)(gpu->kfd2kgd->get_vmem_size(gpu->kgd) >> 32);
1106+ buf[5] = lower_32_bits(local_mem_size);
1107+ buf[6] = upper_32_bits(local_mem_size);
11061108
11071109 for (i = 0, hashout = 0; i < 7; i++)
11081110 hashout ^= hash_32(buf[i], KFD_GPU_ID_HASH_WIDTH);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t