Skip to content

Commit 3e8a61a

Browse files
committed
fixup! rust: drm: sched: Add GPU scheduler abstraction
Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 9290d29 commit 3e8a61a

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

rust/kernel/drm/sched.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//! C header: [`include/drm/gpu_scheduler.h`](../../../../include/drm/gpu_scheduler.h)
66
77
use crate::{
8+
alloc::{box_ext::BoxExt, flags::*},
89
bindings, device,
910
dma_fence::*,
1011
error::{to_result, Result},
@@ -245,7 +246,8 @@ pub struct Entity<T: JobImpl>(Pin<Box<EntityInner<T>>>);
245246
impl<T: JobImpl> Entity<T> {
246247
/// Create a new scheduler entity.
247248
pub fn new(sched: &Scheduler<T>, priority: Priority) -> Result<Self> {
248-
let mut entity: Box<MaybeUninit<EntityInner<T>>> = Box::try_new_zeroed()?;
249+
let mut entity: Box<MaybeUninit<EntityInner<T>>> =
250+
Box::new_uninit(GFP_KERNEL | __GFP_ZERO)?;
249251

250252
let mut sched_ptr = &sched.0.sched as *const _ as *mut _;
251253

@@ -274,7 +276,7 @@ impl<T: JobImpl> Entity<T> {
274276
/// this requires a mutable reference to the entity, ensuring that only one new job can be
275277
/// in flight at once.
276278
pub fn new_job(&mut self, credits: u32, inner: T) -> Result<PendingJob<'_, T>> {
277-
let mut job: Box<MaybeUninit<Job<T>>> = Box::try_new_zeroed()?;
279+
let mut job: Box<MaybeUninit<Job<T>>> = Box::new_uninit(GFP_KERNEL | __GFP_ZERO)?;
278280

279281
// SAFETY: We hold a reference to the entity (which is a valid pointer),
280282
// and the job object was just allocated above.
@@ -335,7 +337,8 @@ impl<T: JobImpl> Scheduler<T> {
335337
timeout_ms: usize,
336338
name: &'static CStr,
337339
) -> Result<Scheduler<T>> {
338-
let mut sched: UniqueArc<MaybeUninit<SchedulerInner<T>>> = UniqueArc::try_new_uninit()?;
340+
let mut sched: UniqueArc<MaybeUninit<SchedulerInner<T>>> =
341+
UniqueArc::new_uninit(GFP_KERNEL)?;
339342

340343
// SAFETY: zero sched->sched_rq as drm_sched_init() uses it to exit early withoput initialisation
341344
// TODO: allocate sched zzeroed instead

0 commit comments

Comments
 (0)