| .. | .. |
|---|
| 41 | 41 | unsigned int *rlib_size, |
|---|
| 42 | 42 | bool *over_subscription) |
|---|
| 43 | 43 | { |
|---|
| 44 | | - unsigned int process_count, queue_count, compute_queue_count; |
|---|
| 44 | + unsigned int process_count, queue_count, compute_queue_count, gws_queue_count; |
|---|
| 45 | 45 | unsigned int map_queue_size; |
|---|
| 46 | 46 | unsigned int max_proc_per_quantum = 1; |
|---|
| 47 | 47 | struct kfd_dev *dev = pm->dqm->dev; |
|---|
| 48 | 48 | |
|---|
| 49 | 49 | process_count = pm->dqm->processes_count; |
|---|
| 50 | | - queue_count = pm->dqm->queue_count; |
|---|
| 51 | | - compute_queue_count = queue_count - pm->dqm->sdma_queue_count; |
|---|
| 50 | + queue_count = pm->dqm->active_queue_count; |
|---|
| 51 | + compute_queue_count = pm->dqm->active_cp_queue_count; |
|---|
| 52 | + gws_queue_count = pm->dqm->gws_queue_count; |
|---|
| 52 | 53 | |
|---|
| 53 | 54 | /* check if there is over subscription |
|---|
| 54 | 55 | * Note: the arbitration between the number of VMIDs and |
|---|
| .. | .. |
|---|
| 61 | 62 | max_proc_per_quantum = dev->max_proc_per_quantum; |
|---|
| 62 | 63 | |
|---|
| 63 | 64 | if ((process_count > max_proc_per_quantum) || |
|---|
| 64 | | - compute_queue_count > get_queues_num(pm->dqm)) { |
|---|
| 65 | + compute_queue_count > get_cp_queues_num(pm->dqm) || |
|---|
| 66 | + gws_queue_count > 1) { |
|---|
| 65 | 67 | *over_subscription = true; |
|---|
| 66 | 68 | pr_debug("Over subscribed runlist\n"); |
|---|
| 67 | 69 | } |
|---|
| .. | .. |
|---|
| 140 | 142 | pm->ib_size_bytes = alloc_size_bytes; |
|---|
| 141 | 143 | |
|---|
| 142 | 144 | pr_debug("Building runlist ib process count: %d queues count %d\n", |
|---|
| 143 | | - pm->dqm->processes_count, pm->dqm->queue_count); |
|---|
| 145 | + pm->dqm->processes_count, pm->dqm->active_queue_count); |
|---|
| 144 | 146 | |
|---|
| 145 | 147 | /* build the run list ib packet */ |
|---|
| 146 | 148 | list_for_each_entry(cur, queues, list) { |
|---|
| .. | .. |
|---|
| 202 | 204 | |
|---|
| 203 | 205 | pr_debug("Finished map process and queues to runlist\n"); |
|---|
| 204 | 206 | |
|---|
| 205 | | - if (is_over_subscription) |
|---|
| 207 | + if (is_over_subscription) { |
|---|
| 208 | + if (!pm->is_over_subscription) |
|---|
| 209 | + pr_warn("Runlist is getting oversubscribed. Expect reduced ROCm performance.\n"); |
|---|
| 206 | 210 | retval = pm->pmf->runlist(pm, &rl_buffer[rl_wptr], |
|---|
| 207 | 211 | *rl_gpu_addr, |
|---|
| 208 | 212 | alloc_size_bytes / sizeof(uint32_t), |
|---|
| 209 | 213 | true); |
|---|
| 214 | + } |
|---|
| 215 | + pm->is_over_subscription = is_over_subscription; |
|---|
| 210 | 216 | |
|---|
| 211 | 217 | for (i = 0; i < alloc_size_bytes / sizeof(uint32_t); i++) |
|---|
| 212 | 218 | pr_debug("0x%2X ", rl_buffer[i]); |
|---|
| .. | .. |
|---|
| 226 | 232 | case CHIP_FIJI: |
|---|
| 227 | 233 | case CHIP_POLARIS10: |
|---|
| 228 | 234 | case CHIP_POLARIS11: |
|---|
| 235 | + case CHIP_POLARIS12: |
|---|
| 236 | + case CHIP_VEGAM: |
|---|
| 229 | 237 | pm->pmf = &kfd_vi_pm_funcs; |
|---|
| 230 | 238 | break; |
|---|
| 231 | 239 | case CHIP_VEGA10: |
|---|
| 240 | + case CHIP_VEGA12: |
|---|
| 241 | + case CHIP_VEGA20: |
|---|
| 232 | 242 | case CHIP_RAVEN: |
|---|
| 243 | + case CHIP_RENOIR: |
|---|
| 244 | + case CHIP_ARCTURUS: |
|---|
| 245 | + case CHIP_NAVI10: |
|---|
| 246 | + case CHIP_NAVI12: |
|---|
| 247 | + case CHIP_NAVI14: |
|---|
| 248 | + case CHIP_SIENNA_CICHLID: |
|---|
| 249 | + case CHIP_NAVY_FLOUNDER: |
|---|
| 233 | 250 | pm->pmf = &kfd_v9_pm_funcs; |
|---|
| 234 | 251 | break; |
|---|
| 235 | 252 | default: |
|---|
| .. | .. |
|---|
| 250 | 267 | return 0; |
|---|
| 251 | 268 | } |
|---|
| 252 | 269 | |
|---|
| 253 | | -void pm_uninit(struct packet_manager *pm) |
|---|
| 270 | +void pm_uninit(struct packet_manager *pm, bool hanging) |
|---|
| 254 | 271 | { |
|---|
| 255 | 272 | mutex_destroy(&pm->lock); |
|---|
| 256 | | - kernel_queue_uninit(pm->priv_queue); |
|---|
| 273 | + kernel_queue_uninit(pm->priv_queue, hanging); |
|---|
| 257 | 274 | } |
|---|
| 258 | 275 | |
|---|
| 259 | 276 | int pm_send_set_resources(struct packet_manager *pm, |
|---|
| .. | .. |
|---|
| 264 | 281 | |
|---|
| 265 | 282 | size = pm->pmf->set_resources_size; |
|---|
| 266 | 283 | mutex_lock(&pm->lock); |
|---|
| 267 | | - pm->priv_queue->ops.acquire_packet_buffer(pm->priv_queue, |
|---|
| 284 | + kq_acquire_packet_buffer(pm->priv_queue, |
|---|
| 268 | 285 | size / sizeof(uint32_t), |
|---|
| 269 | 286 | (unsigned int **)&buffer); |
|---|
| 270 | 287 | if (!buffer) { |
|---|
| .. | .. |
|---|
| 275 | 292 | |
|---|
| 276 | 293 | retval = pm->pmf->set_resources(pm, buffer, res); |
|---|
| 277 | 294 | if (!retval) |
|---|
| 278 | | - pm->priv_queue->ops.submit_packet(pm->priv_queue); |
|---|
| 295 | + kq_submit_packet(pm->priv_queue); |
|---|
| 279 | 296 | else |
|---|
| 280 | | - pm->priv_queue->ops.rollback_packet(pm->priv_queue); |
|---|
| 297 | + kq_rollback_packet(pm->priv_queue); |
|---|
| 281 | 298 | |
|---|
| 282 | 299 | out: |
|---|
| 283 | 300 | mutex_unlock(&pm->lock); |
|---|
| .. | .. |
|---|
| 302 | 319 | packet_size_dwords = pm->pmf->runlist_size / sizeof(uint32_t); |
|---|
| 303 | 320 | mutex_lock(&pm->lock); |
|---|
| 304 | 321 | |
|---|
| 305 | | - retval = pm->priv_queue->ops.acquire_packet_buffer(pm->priv_queue, |
|---|
| 322 | + retval = kq_acquire_packet_buffer(pm->priv_queue, |
|---|
| 306 | 323 | packet_size_dwords, &rl_buffer); |
|---|
| 307 | 324 | if (retval) |
|---|
| 308 | 325 | goto fail_acquire_packet_buffer; |
|---|
| .. | .. |
|---|
| 312 | 329 | if (retval) |
|---|
| 313 | 330 | goto fail_create_runlist; |
|---|
| 314 | 331 | |
|---|
| 315 | | - pm->priv_queue->ops.submit_packet(pm->priv_queue); |
|---|
| 332 | + kq_submit_packet(pm->priv_queue); |
|---|
| 316 | 333 | |
|---|
| 317 | 334 | mutex_unlock(&pm->lock); |
|---|
| 318 | 335 | |
|---|
| 319 | 336 | return retval; |
|---|
| 320 | 337 | |
|---|
| 321 | 338 | fail_create_runlist: |
|---|
| 322 | | - pm->priv_queue->ops.rollback_packet(pm->priv_queue); |
|---|
| 339 | + kq_rollback_packet(pm->priv_queue); |
|---|
| 323 | 340 | fail_acquire_packet_buffer: |
|---|
| 324 | 341 | mutex_unlock(&pm->lock); |
|---|
| 325 | 342 | fail_create_runlist_ib: |
|---|
| .. | .. |
|---|
| 328 | 345 | } |
|---|
| 329 | 346 | |
|---|
| 330 | 347 | int pm_send_query_status(struct packet_manager *pm, uint64_t fence_address, |
|---|
| 331 | | - uint32_t fence_value) |
|---|
| 348 | + uint64_t fence_value) |
|---|
| 332 | 349 | { |
|---|
| 333 | 350 | uint32_t *buffer, size; |
|---|
| 334 | 351 | int retval = 0; |
|---|
| .. | .. |
|---|
| 338 | 355 | |
|---|
| 339 | 356 | size = pm->pmf->query_status_size; |
|---|
| 340 | 357 | mutex_lock(&pm->lock); |
|---|
| 341 | | - pm->priv_queue->ops.acquire_packet_buffer(pm->priv_queue, |
|---|
| 358 | + kq_acquire_packet_buffer(pm->priv_queue, |
|---|
| 342 | 359 | size / sizeof(uint32_t), (unsigned int **)&buffer); |
|---|
| 343 | 360 | if (!buffer) { |
|---|
| 344 | 361 | pr_err("Failed to allocate buffer on kernel queue\n"); |
|---|
| .. | .. |
|---|
| 348 | 365 | |
|---|
| 349 | 366 | retval = pm->pmf->query_status(pm, buffer, fence_address, fence_value); |
|---|
| 350 | 367 | if (!retval) |
|---|
| 351 | | - pm->priv_queue->ops.submit_packet(pm->priv_queue); |
|---|
| 368 | + kq_submit_packet(pm->priv_queue); |
|---|
| 352 | 369 | else |
|---|
| 353 | | - pm->priv_queue->ops.rollback_packet(pm->priv_queue); |
|---|
| 370 | + kq_rollback_packet(pm->priv_queue); |
|---|
| 354 | 371 | |
|---|
| 355 | 372 | out: |
|---|
| 356 | 373 | mutex_unlock(&pm->lock); |
|---|
| .. | .. |
|---|
| 367 | 384 | |
|---|
| 368 | 385 | size = pm->pmf->unmap_queues_size; |
|---|
| 369 | 386 | mutex_lock(&pm->lock); |
|---|
| 370 | | - pm->priv_queue->ops.acquire_packet_buffer(pm->priv_queue, |
|---|
| 387 | + kq_acquire_packet_buffer(pm->priv_queue, |
|---|
| 371 | 388 | size / sizeof(uint32_t), (unsigned int **)&buffer); |
|---|
| 372 | 389 | if (!buffer) { |
|---|
| 373 | 390 | pr_err("Failed to allocate buffer on kernel queue\n"); |
|---|
| .. | .. |
|---|
| 378 | 395 | retval = pm->pmf->unmap_queues(pm, buffer, type, filter, filter_param, |
|---|
| 379 | 396 | reset, sdma_engine); |
|---|
| 380 | 397 | if (!retval) |
|---|
| 381 | | - pm->priv_queue->ops.submit_packet(pm->priv_queue); |
|---|
| 398 | + kq_submit_packet(pm->priv_queue); |
|---|
| 382 | 399 | else |
|---|
| 383 | | - pm->priv_queue->ops.rollback_packet(pm->priv_queue); |
|---|
| 400 | + kq_rollback_packet(pm->priv_queue); |
|---|
| 384 | 401 | |
|---|
| 385 | 402 | out: |
|---|
| 386 | 403 | mutex_unlock(&pm->lock); |
|---|
| .. | .. |
|---|
| 425 | 442 | |
|---|
| 426 | 443 | size = pm->pmf->query_status_size; |
|---|
| 427 | 444 | mutex_lock(&pm->lock); |
|---|
| 428 | | - pm->priv_queue->ops.acquire_packet_buffer(pm->priv_queue, |
|---|
| 445 | + kq_acquire_packet_buffer(pm->priv_queue, |
|---|
| 429 | 446 | size / sizeof(uint32_t), (unsigned int **)&buffer); |
|---|
| 430 | 447 | if (!buffer) { |
|---|
| 431 | 448 | pr_err("Failed to allocate buffer on kernel queue\n"); |
|---|
| .. | .. |
|---|
| 433 | 450 | goto out; |
|---|
| 434 | 451 | } |
|---|
| 435 | 452 | memset(buffer, 0x55, size); |
|---|
| 436 | | - pm->priv_queue->ops.submit_packet(pm->priv_queue); |
|---|
| 453 | + kq_submit_packet(pm->priv_queue); |
|---|
| 437 | 454 | |
|---|
| 438 | 455 | pr_info("Submitting %x %x %x %x %x %x %x to HIQ to hang the HWS.", |
|---|
| 439 | 456 | buffer[0], buffer[1], buffer[2], buffer[3], |
|---|