Skip to content

Commit 9a0732d

Browse files
committed
drm/asahi: object,alloc: Drop new_prealloc()
All users are now converted to new_init_prealloc() Signed-off-by: Asahi Lina <[email protected]>
1 parent b4c78e8 commit 9a0732d

2 files changed

Lines changed: 0 additions & 64 deletions

File tree

drivers/gpu/drm/asahi/alloc.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -249,24 +249,6 @@ pub(crate) trait Allocator {
249249
GpuObject::<T, GenericAlloc<T, Self::Raw>>::new_default(self.alloc_object()?)
250250
}
251251

252-
/// Allocate a new GpuStruct object. See [`GpuObject::new_prealloc`].
253-
#[inline(never)]
254-
fn new_prealloc<T: GpuStruct>(
255-
&mut self,
256-
inner_cb: impl FnOnce(GpuWeakPointer<T>) -> Result<Box<T>>,
257-
raw_cb: impl for<'a> FnOnce(
258-
&'a T,
259-
&'a mut MaybeUninit<T::Raw<'a>>,
260-
GpuWeakPointer<T>,
261-
) -> Result<&'a mut T::Raw<'a>>,
262-
) -> Result<GpuObject<T, GenericAlloc<T, Self::Raw>>> {
263-
GpuObject::<T, GenericAlloc<T, Self::Raw>>::new_prealloc(
264-
self.alloc_object()?,
265-
inner_cb,
266-
raw_cb,
267-
)
268-
}
269-
270252
/// Allocate a new GpuStruct object. See [`GpuObject::new_init_prealloc`].
271253
#[inline(never)]
272254
fn new_init_prealloc<

drivers/gpu/drm/asahi/object.rs

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -334,52 +334,6 @@ impl<T: GpuStruct, U: Allocation<T>> GpuObject<T, U> {
334334
GpuObject::<T, U>::new_boxed(alloc, Box::try_new(inner)?, callback)
335335
}
336336

337-
/// Create a new GpuObject given an allocator, with callback-based initialization.
338-
///
339-
/// This is used when the construction of the `T` type requires knowing the GPU VA address of
340-
/// the structure that is being constructed ahead of time. The first callback constructs a
341-
/// `Box<T>` given the pointer to the about-to-be-initialized GPU structure, and the second
342-
/// callback initializes that structure as in `new_boxed`.
343-
pub(crate) fn new_prealloc(
344-
alloc: U,
345-
inner_cb: impl FnOnce(GpuWeakPointer<T>) -> Result<Box<T>>,
346-
raw_cb: impl for<'a> FnOnce(
347-
&'a T,
348-
&'a mut MaybeUninit<T::Raw<'a>>,
349-
GpuWeakPointer<T>,
350-
) -> Result<&'a mut T::Raw<'a>>,
351-
) -> Result<Self> {
352-
if alloc.size() < mem::size_of::<T::Raw<'static>>() {
353-
return Err(ENOMEM);
354-
}
355-
let gpu_ptr =
356-
GpuWeakPointer::<T>(NonZeroU64::new(alloc.gpu_ptr()).ok_or(EINVAL)?, PhantomData);
357-
mod_dev_dbg!(
358-
alloc.device(),
359-
"Allocating {} @ {:#x}\n",
360-
core::any::type_name::<T>(),
361-
alloc.gpu_ptr()
362-
);
363-
let inner = inner_cb(gpu_ptr)?;
364-
let p = alloc.ptr().ok_or(EINVAL)?.as_ptr() as *mut MaybeUninit<T::Raw<'_>>;
365-
// SAFETY: `p` is guaranteed to be valid per the Allocation invariant.
366-
let raw = raw_cb(&*inner, unsafe { &mut *p }, gpu_ptr)?;
367-
if p as *mut T::Raw<'_> != raw as *mut _ {
368-
dev_err!(
369-
alloc.device(),
370-
"Allocation callback returned a mismatched reference ({})\n",
371-
core::any::type_name::<T>(),
372-
);
373-
return Err(EINVAL);
374-
}
375-
Ok(Self {
376-
raw: p as *mut u8 as *mut T::Raw<'static>,
377-
gpu_ptr,
378-
alloc,
379-
inner,
380-
})
381-
}
382-
383337
/// Create a new GpuObject given an allocator and the boxed inner data (a type implementing
384338
/// GpuStruct).
385339
///

0 commit comments

Comments
 (0)