On Wed, 2026-04-29 at 08:19 +0000, Alice Ryhl wrote:
obj: Opaquebindings::drm_gem_shmem_object, /// Parent object that owns this object's DMA reservation object. parent_resv_obj: Option<ARef<Object<T>>>, + /// Devres object for unmapping any SGTable on driver-unbind. + /// TODO: Drop the mutex once we can use Init with SetOnce. + #[pin] + sgt_res: Mutex<SetOnce<Devres<SGTableMap<T>>>>,
As far as I can tell, you don't need this Mutex. Also, it causes problems like requiring the reference transmute below.
We do actually need the mutex, see the discussions on the older versions of the patch series that I had with Alexandre. The only alternative is the ability to pass a impl Init<_, Error> to SetOnce::populate. Whcih is because Devres setup can fail, and we can only have one Devres resource for SGTableMap at a time for a given gem object because dropping the Devres also releases the sgt table. So trying to do this without a lock would imply creating a Devres, attempting to pass it to populate (it could have been populated between creation and populating the devres), and then destroying a potentially redundant Devres that will drop the SGT resources that the prior Devres instance would be responsible for unmapping.