Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdkfd: Remove sync_with_hw() from amdkfd

This patch completely removes the sync_with_hw() because it was broken and
actually there is no point of using it.

This function was used to:

- Make sure that the submitted packet to the HIQ (which is a kernel queue) was
read by the CP. However, it was discovered that the method this function used
to do that (checking wptr == rptr) is not consistent with how the actual CP
firmware works in all cases.

- Make sure that the queue is empty before issuing the next packet. To achieve
that, the function blocked amdkfd from continuing until the recently
submitted packet was consumed. However, the acquire_packet_buffer() already
checks if there is enough room for a new packet so calling sync_with_hw() is
redundant.

Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>

-30
-24
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
··· 262 262 kq->pending_wptr); 263 263 } 264 264 265 - static int sync_with_hw(struct kernel_queue *kq, unsigned long timeout_ms) 266 - { 267 - unsigned long org_timeout_ms; 268 - 269 - BUG_ON(!kq); 270 - 271 - org_timeout_ms = timeout_ms; 272 - timeout_ms += jiffies * 1000 / HZ; 273 - while (*kq->wptr_kernel != *kq->rptr_kernel) { 274 - if (time_after(jiffies * 1000 / HZ, timeout_ms)) { 275 - pr_err("kfd: kernel_queue %s timeout expired %lu\n", 276 - __func__, org_timeout_ms); 277 - pr_err("kfd: wptr: %d rptr: %d\n", 278 - *kq->wptr_kernel, *kq->rptr_kernel); 279 - return -ETIME; 280 - } 281 - schedule(); 282 - } 283 - 284 - return 0; 285 - } 286 - 287 265 static void rollback_packet(struct kernel_queue *kq) 288 266 { 289 267 BUG_ON(!kq); ··· 283 305 kq->ops.uninitialize = uninitialize; 284 306 kq->ops.acquire_packet_buffer = acquire_packet_buffer; 285 307 kq->ops.submit_packet = submit_packet; 286 - kq->ops.sync_with_hw = sync_with_hw; 287 308 kq->ops.rollback_packet = rollback_packet; 288 309 289 310 switch (dev->device_info->asic_family) { ··· 326 349 for (i = 0; i < 5; i++) 327 350 buffer[i] = kq->nop_packet; 328 351 kq->ops.submit_packet(kq); 329 - kq->ops.sync_with_hw(kq, 1000); 330 352 331 353 pr_err("kfd: ending kernel queue test\n"); 332 354 }
-2
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.h
··· 61 61 unsigned int **buffer_ptr); 62 62 63 63 void (*submit_packet)(struct kernel_queue *kq); 64 - int (*sync_with_hw)(struct kernel_queue *kq, 65 - unsigned long timeout_ms); 66 64 void (*rollback_packet)(struct kernel_queue *kq); 67 65 }; 68 66
-4
drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c
··· 376 376 packet->queue_mask_hi = upper_32_bits(res->queue_mask); 377 377 378 378 pm->priv_queue->ops.submit_packet(pm->priv_queue); 379 - pm->priv_queue->ops.sync_with_hw(pm->priv_queue, KFD_HIQ_TIMEOUT); 380 379 381 380 mutex_unlock(&pm->lock); 382 381 ··· 412 413 goto fail_create_runlist; 413 414 414 415 pm->priv_queue->ops.submit_packet(pm->priv_queue); 415 - pm->priv_queue->ops.sync_with_hw(pm->priv_queue, KFD_HIQ_TIMEOUT); 416 416 417 417 mutex_unlock(&pm->lock); 418 418 ··· 458 460 packet->data_lo = lower_32_bits((uint64_t)fence_value); 459 461 460 462 pm->priv_queue->ops.submit_packet(pm->priv_queue); 461 - pm->priv_queue->ops.sync_with_hw(pm->priv_queue, KFD_HIQ_TIMEOUT); 462 463 mutex_unlock(&pm->lock); 463 464 464 465 return 0; ··· 535 538 }; 536 539 537 540 pm->priv_queue->ops.submit_packet(pm->priv_queue); 538 - pm->priv_queue->ops.sync_with_hw(pm->priv_queue, KFD_HIQ_TIMEOUT); 539 541 540 542 mutex_unlock(&pm->lock); 541 543 return 0;