Hi Danilo,
On 10/15/25 22:04, Danilo Krummrich wrote:
>> diff --git a/drivers/gpu/nova-core/dma.rs b/drivers/gpu/nova-core/dma.rs
>> index 94f44bcfd748..639a99cf72c4 100644
>> --- a/drivers/gpu/nova-core/dma.rs
>> +++ b/drivers/gpu/nova-core/dma.rs
>> @@ -25,21 +25,11 @@ pub(crate) fn new(dev: &device::Device<device::Bound>,
>> len: usize) -> Result<Sel
>> }
>>
>> pub(crate) fn from_data(dev: &device::Device<device::Bound>, data:
>> &[u8]) -> Result<Self> {
>> - Self::new(dev, data.len()).map(|mut dma_obj| {
>> - // TODO[COHA]: replace with `CoherentAllocation::write()` once
>> available.
>> - // SAFETY:
>> - // - `dma_obj`'s size is at least `data.len()`.
>> - // - We have just created this object and there is no other
>> user at this stage.
>> - unsafe {
>> - core::ptr::copy_nonoverlapping(
>> - data.as_ptr(),
>> - dma_obj.dma.start_ptr_mut(),
>> - data.len(),
>> - );
>> - }
>> -
>> - dma_obj
>> - })
>> + let mut dma_obj = Self::new(dev, data.len())?;
>> + // SAFETY: We have just created this object and there is no other
>> user at this stage.
>
> The safety comment should rather confirm that it is guaranteed that the device
> won't access this memory concurrently.
I actually don't know how this is guaranteed. It wasn't explicitly
explained before here, although unless I'm mistaken it was already a
requirement. Could you help me? I guess it's related to the already
mentioned fact that we just allocated this DMA memory and the device
isn't yet initialized?
Thanks,
Daniel