@@ -37,7 +37,6 @@ use crate::fw::buffer;
3737use crate :: fw:: types:: * ;
3838use crate :: util:: * ;
3939use crate :: { alloc, fw, gpu, hw, mmu, slotalloc} ;
40- use crate :: { box_in_place, place} ;
4140use core:: sync:: atomic:: Ordering ;
4241use kernel:: prelude:: * ;
4342use kernel:: sync:: { Arc , Mutex } ;
@@ -335,17 +334,19 @@ impl Buffer::ver {
335334 let preempt2_size = num_clusters_adj * gpu. get_cfg ( ) . preempt2_size ;
336335 let preempt3_size = num_clusters_adj * gpu. get_cfg ( ) . preempt3_size ;
337336
338- let inner = box_in_place ! ( buffer:: Info :: ver {
339- block_ctl: alloc. shared. new_default:: <buffer:: BlockControl >( ) ?,
340- counter: alloc. shared. new_default:: <buffer:: Counter >( ) ?,
341- page_list: ualloc_priv. lock( ) . array_empty( max_pages) ?,
342- block_list: ualloc_priv. lock( ) . array_empty( max_blocks * 2 ) ?,
343- } ) ?;
344-
345- let info = alloc. private . new_boxed ( inner, |inner, ptr| {
346- Ok ( place ! (
347- ptr,
348- buffer:: raw:: Info :: ver {
337+ let shared = & mut alloc. shared ;
338+ let info = alloc. private . new_init (
339+ {
340+ let ualloc_priv = & ualloc_priv;
341+ try_init ! ( buffer:: Info :: ver {
342+ block_ctl: shared. new_default:: <buffer:: BlockControl >( ) ?,
343+ counter: shared. new_default:: <buffer:: Counter >( ) ?,
344+ page_list: ualloc_priv. lock( ) . array_empty( max_pages) ?,
345+ block_list: ualloc_priv. lock( ) . array_empty( max_blocks * 2 ) ?,
346+ } )
347+ } ,
348+ |inner, _p| {
349+ try_init ! ( buffer:: raw:: Info :: ver {
349350 gpu_counter: 0x0 ,
350351 unk_4: 0 ,
351352 last_id: 0x0 ,
@@ -379,9 +380,9 @@ impl Buffer::ver {
379380 max_pages_nomemless: max_pages_nomemless. try_into( ) ?,
380381 unk_8c: 0x0 ,
381382 unk_90: Default :: default ( ) ,
382- }
383- ) )
384- } ) ?;
383+ } )
384+ } ,
385+ ) ?;
385386
386387 // Technically similar to Scene below, let's play it safe.
387388 let kernel_buffer = alloc. shared . array_empty ( 0x40 ) ?;
@@ -590,33 +591,33 @@ impl Buffer::ver {
590591 None
591592 } ;
592593
593- let scene_inner = box_in_place ! ( buffer:: Scene :: ver {
594- user_buffer: user_buffer,
595- buffer: self . clone( ) ,
596- tvb_heapmeta: tvb_heapmeta,
597- tvb_tilemap: tvb_tilemap,
598- tpc: tpc,
599- clustering: clustering,
600- preempt_buf: preempt_buf,
601- seq_buf: seq_buf,
602- #[ ver( G >= G14X ) ]
603- control_word: alloc. gpu. array_empty( 1 ) ?,
604- } ) ?;
605-
606594 // Could be made strong, but we wind up with a deadlock if we try to grab the
607595 // pointer through the inner.buffer path inside the closure.
608596 let stats_pointer = inner. stats . weak_pointer ( ) ;
609597
598+ let _gpu = & mut alloc. gpu ;
599+
610600 // macOS allocates this as private. However, the firmware does not
611601 // DC CIVAC this before reading it (like it does most other things),
612602 // which causes odd cache incoherency bugs when combined with
613603 // speculation on the firmware side (maybe). This doesn't happen
614604 // on macOS because these structs are a circular pool that is mapped
615605 // already initialized. Just mark this shared for now.
616- let scene = alloc. shared . new_boxed ( scene_inner, |inner, ptr| {
617- Ok ( place ! (
618- ptr,
619- buffer:: raw:: Scene :: ver {
606+ let scene = alloc. shared . new_init (
607+ try_init ! ( buffer:: Scene :: ver {
608+ user_buffer: user_buffer,
609+ buffer: self . clone( ) ,
610+ tvb_heapmeta: tvb_heapmeta,
611+ tvb_tilemap: tvb_tilemap,
612+ tpc: tpc,
613+ clustering: clustering,
614+ preempt_buf: preempt_buf,
615+ seq_buf: seq_buf,
616+ #[ ver( G >= G14X ) ]
617+ control_word: _gpu. array_empty( 1 ) ?,
618+ } ) ,
619+ |inner, _p| {
620+ try_init ! ( buffer:: raw:: Scene :: ver {
620621 #[ ver( G >= G14X ) ]
621622 control_word: inner. control_word. gpu_pointer( ) ,
622623 #[ ver( G >= G14X ) ]
@@ -635,9 +636,9 @@ impl Buffer::ver {
635636 unk_30: U64 ( 0 ) ,
636637 #[ ver( G < G14X ) ]
637638 unk_38: U64 ( 0 ) ,
638- }
639- ) )
640- } ) ?;
639+ } )
640+ } ,
641+ ) ?;
641642
642643 let mut rebind = false ;
643644
0 commit comments