Skip to content

Commit d1d0846

Browse files
committed
drm/asahi: slotalloc: Allow initializing empty slots
These slots can never be used. Signed-off-by: Asahi Lina <[email protected]>
1 parent 8d0da0c commit d1d0846

4 files changed

Lines changed: 11 additions & 9 deletions

File tree

drivers/gpu/drm/asahi/buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ impl BufferManager::ver {
734734
Ok(BufferManager::ver(slotalloc::SlotAllocator::new(
735735
NUM_BUFFERS,
736736
BufferManagerInner::ver { owners },
737-
|_inner, _slot| BufferSlotInner::ver(),
737+
|_inner, _slot| Some(BufferSlotInner::ver()),
738738
c_str!("BufferManager::SlotAllocator"),
739739
static_lock_class!(),
740740
static_lock_class!(),

drivers/gpu/drm/asahi/event.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,12 @@ impl EventManager {
154154
alloc: slotalloc::SlotAllocator::new(
155155
NUM_EVENTS,
156156
inner,
157-
|inner: &mut EventManagerInner, slot| EventInner {
158-
stamp: &inner.stamps[slot as usize].0,
159-
gpu_stamp: inner.stamps.weak_item_pointer(slot as usize),
160-
gpu_fw_stamp: inner.fw_stamps.weak_item_pointer(slot as usize),
157+
|inner: &mut EventManagerInner, slot| {
158+
Some(EventInner {
159+
stamp: &inner.stamps[slot as usize].0,
160+
gpu_stamp: inner.stamps.weak_item_pointer(slot as usize),
161+
gpu_fw_stamp: inner.fw_stamps.weak_item_pointer(slot as usize),
162+
})
161163
},
162164
c_str!("EventManager::SlotAllocator"),
163165
static_lock_class!(),

drivers/gpu/drm/asahi/mmu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ impl Uat {
12031203
slots: slotalloc::SlotAllocator::new(
12041204
UAT_USER_CTX as u32,
12051205
(),
1206-
|_inner, _slot| SlotInner(),
1206+
|_inner, _slot| Some(SlotInner()),
12071207
c_str!("Uat::SlotAllocator"),
12081208
static_lock_class!(),
12091209
static_lock_class!(),

drivers/gpu/drm/asahi/slotalloc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl<T: SlotItem> SlotAllocator<T> {
130130
pub(crate) fn new(
131131
num_slots: u32,
132132
mut data: T::Data,
133-
mut constructor: impl FnMut(&mut T::Data, u32) -> T,
133+
mut constructor: impl FnMut(&mut T::Data, u32) -> Option<T>,
134134
name: &'static CStr,
135135
lock_key1: LockClassKey,
136136
lock_key2: LockClassKey,
@@ -139,8 +139,8 @@ impl<T: SlotItem> SlotAllocator<T> {
139139

140140
for i in 0..num_slots {
141141
slots
142-
.try_push(Some(Entry {
143-
item: constructor(&mut data, i),
142+
.try_push(constructor(&mut data, i).map(|item| Entry {
143+
item,
144144
get_time: 0,
145145
drop_time: 0,
146146
}))

0 commit comments

Comments
 (0)