mirror of
https://github.com/torvalds/linux.git
synced 2026-12-06 13:23:45 +00:00
Xe, is a new driver for Intel GPUs that supports both integrated and discrete platforms starting with Tiger Lake (first Intel Xe Architecture). The code is at a stage where it is already functional and has experimental support for multiple platforms starting from Tiger Lake, with initial support implemented in Mesa (for Iris and Anv, our OpenGL and Vulkan drivers), as well as in NEO (for OpenCL and Level0). The new Xe driver leverages a lot from i915. As for display, the intent is to share the display code with the i915 driver so that there is maximum reuse there. But it is not added in this patch. This initial work is a collaboration of many people and unfortunately the big squashed patch won't fully honor the proper credits. But let's get some git quick stats so we can at least try to preserve some of the credits: Co-developed-by: Matthew Brost <[email protected]> Co-developed-by: Matthew Auld <[email protected]> Co-developed-by: Matt Roper <[email protected]> Co-developed-by: Thomas Hellström <[email protected]> Co-developed-by: Francois Dugast <[email protected]> Co-developed-by: Lucas De Marchi <[email protected]> Co-developed-by: Maarten Lankhorst <[email protected]> Co-developed-by: Philippe Lecluse <[email protected]> Co-developed-by: Nirmoy Das <[email protected]> Co-developed-by: Jani Nikula <[email protected]> Co-developed-by: José Roberto de Souza <[email protected]> Co-developed-by: Rodrigo Vivi <[email protected]> Co-developed-by: Dave Airlie <[email protected]> Co-developed-by: Faith Ekstrand <[email protected]> Co-developed-by: Daniel Vetter <[email protected]> Co-developed-by: Mauro Carvalho Chehab <[email protected]> Signed-off-by: Rodrigo Vivi <[email protected]> Signed-off-by: Matthew Brost <[email protected]>
102 lines
2.5 KiB
C
102 lines
2.5 KiB
C
// SPDX-License-Identifier: MIT
|
|
/*
|
|
* Copyright © 2023 Intel Corporation
|
|
*/
|
|
|
|
#include "xe_gpu_scheduler.h"
|
|
|
|
static void xe_sched_process_msg_queue(struct xe_gpu_scheduler *sched)
|
|
{
|
|
if (!READ_ONCE(sched->base.pause_submit))
|
|
queue_work(sched->base.submit_wq, &sched->work_process_msg);
|
|
}
|
|
|
|
static void xe_sched_process_msg_queue_if_ready(struct xe_gpu_scheduler *sched)
|
|
{
|
|
struct xe_sched_msg *msg;
|
|
|
|
spin_lock(&sched->base.job_list_lock);
|
|
msg = list_first_entry_or_null(&sched->msgs, struct xe_sched_msg, link);
|
|
if (msg)
|
|
xe_sched_process_msg_queue(sched);
|
|
spin_unlock(&sched->base.job_list_lock);
|
|
}
|
|
|
|
static struct xe_sched_msg *
|
|
xe_sched_get_msg(struct xe_gpu_scheduler *sched)
|
|
{
|
|
struct xe_sched_msg *msg;
|
|
|
|
spin_lock(&sched->base.job_list_lock);
|
|
msg = list_first_entry_or_null(&sched->msgs,
|
|
struct xe_sched_msg, link);
|
|
if (msg)
|
|
list_del(&msg->link);
|
|
spin_unlock(&sched->base.job_list_lock);
|
|
|
|
return msg;
|
|
}
|
|
|
|
static void xe_sched_process_msg_work(struct work_struct *w)
|
|
{
|
|
struct xe_gpu_scheduler *sched =
|
|
container_of(w, struct xe_gpu_scheduler, work_process_msg);
|
|
struct xe_sched_msg *msg;
|
|
|
|
if (READ_ONCE(sched->base.pause_submit))
|
|
return;
|
|
|
|
msg = xe_sched_get_msg(sched);
|
|
if (msg) {
|
|
sched->ops->process_msg(msg);
|
|
|
|
xe_sched_process_msg_queue_if_ready(sched);
|
|
}
|
|
}
|
|
|
|
int xe_sched_init(struct xe_gpu_scheduler *sched,
|
|
const struct drm_sched_backend_ops *ops,
|
|
const struct xe_sched_backend_ops *xe_ops,
|
|
struct workqueue_struct *submit_wq,
|
|
uint32_t hw_submission, unsigned hang_limit,
|
|
long timeout, struct workqueue_struct *timeout_wq,
|
|
atomic_t *score, const char *name,
|
|
struct device *dev)
|
|
{
|
|
sched->ops = xe_ops;
|
|
INIT_LIST_HEAD(&sched->msgs);
|
|
INIT_WORK(&sched->work_process_msg, xe_sched_process_msg_work);
|
|
|
|
return drm_sched_init(&sched->base, ops, submit_wq, 1, hw_submission,
|
|
hang_limit, timeout, timeout_wq, score, name,
|
|
dev);
|
|
}
|
|
|
|
void xe_sched_fini(struct xe_gpu_scheduler *sched)
|
|
{
|
|
xe_sched_submission_stop(sched);
|
|
drm_sched_fini(&sched->base);
|
|
}
|
|
|
|
void xe_sched_submission_start(struct xe_gpu_scheduler *sched)
|
|
{
|
|
drm_sched_wqueue_start(&sched->base);
|
|
queue_work(sched->base.submit_wq, &sched->work_process_msg);
|
|
}
|
|
|
|
void xe_sched_submission_stop(struct xe_gpu_scheduler *sched)
|
|
{
|
|
drm_sched_wqueue_stop(&sched->base);
|
|
cancel_work_sync(&sched->work_process_msg);
|
|
}
|
|
|
|
void xe_sched_add_msg(struct xe_gpu_scheduler *sched,
|
|
struct xe_sched_msg *msg)
|
|
{
|
|
spin_lock(&sched->base.job_list_lock);
|
|
list_add_tail(&msg->link, &sched->msgs);
|
|
spin_unlock(&sched->base.job_list_lock);
|
|
|
|
xe_sched_process_msg_queue(sched);
|
|
}
|