From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f73.google.com (mail-ed1-f73.google.com [209.85.208.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 417533806A2 for ; Tue, 17 Mar 2026 06:52:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773730344; cv=none; b=iTTery1hABIiRXlxhC8PCifkgs6TCbytEgljp+GXxZRSfs4CH7c3YWwDBoJBU1F71/wHt0nGL2RBhGzRM7cKirFuKBwonwDGRhXioJCnMIlNyTBcyhHUVW+iZpvevtB6dPulpdVnlZZAlGGkbIKF+OBlntA0XvUq/XRfgv9+xkY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773730344; c=relaxed/simple; bh=3R1SS/JCZM/Lfoc9w7kAsHUSiEC8aTlug28cBDnn6ZI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=enco7/tUbrxCIn7Uy4ew6ysnQQnomfKQDIbr4LCoP2p4IITTXwNf2ZNXoEi8wtUkD7JBzL+2ALF1xY0Pq+tvP26UflbQMe4ts4boYCuNTeNi8NveTD6rwm5eEN71q0UA8Dnfku30iKUxTbxxTOQ+KP1PTloEtoBKd6uyut4KoD4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=dtUNpygu; arc=none smtp.client-ip=209.85.208.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="dtUNpygu" Received: by mail-ed1-f73.google.com with SMTP id 4fb4d7f45d1cf-666fb8bc344so718951a12.0 for ; Mon, 16 Mar 2026 23:52:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773730340; x=1774335140; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=FV64adRB9qOuDZltuxVkHORmf9URma8WDk8N3r49JmA=; b=dtUNpyguVuV8OqvQNkj7mtpD9/iAAgNvDd3xf8tWEy3Q/r+fGpP/P5CY5F14HXocD/ VT4b2qw/zMwHtz/CU9wqyiHe2jAztdnJr0Uw7hyfqg6z0bMGSjs/MdFGiYJoP2Q/993R c7HKkjSp87LHM65aYgs9T7qG72iBorKzicTbKxPxc8Pzy90hQ3c+nzWJQCA/Nh3hpieV pFaYnjZfoqEBQw2C9frxpl9F5Po0mpZZD1qkpta5zBLGESjpT5R2yMi/qo4jqgJiVOlz RrVFQXM+nSYirLQyhVBeoxPMfSOFaTPGjrBCZT+TdBNWHUN+iz0Du+VaEBrW9bNa5zKy yipQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773730340; x=1774335140; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FV64adRB9qOuDZltuxVkHORmf9URma8WDk8N3r49JmA=; b=lgcWyzobx+7OqQhxV3lNGlQmTcvmOZt8YkHhKqJHxZvbK4YAnvK5nxKUtf7AfA3ywX xdh2UFjq/SAVmwWEEltbtCYrTdeNFeSp1NgjCEBX5alFDNeDhOSussA8WAvi/772BH8m fL+5k2atE1qjkqfewNGQVtlyen6axntYfgMBumXXCVFaIQxfUaC7VO74FTJyew27B7Da yP6hx30CURBZZqd6j1TKvYZN4nggBOAyCOsb6MJW75XegDB5MRekMLMAughgqZ9xW6YL gCVYSixt8uSaJnwLgW2bP9xL5ZURYaM4KBZf0QB7/pm2BW/PF4mGXB3htOnNIP04FvP/ BVzw== X-Forwarded-Encrypted: i=1; AJvYcCVFpITJXmpWijjSl6B06WrvzViqiN/ICiPvQ6wDNPkiqW+oD/sLZ2Mc/o7w1L9g6FDNrwsm3wA3wJJGZrs=@vger.kernel.org X-Gm-Message-State: AOJu0Yy+4QOuUc3heFP3of9yv/5F89lGvKDYbeE3YeoT7vL80wG4ktSs JB6qsWZooxSSooStzKJmXFM39U+owEwEVPPKUYOqbLsDpcR97ZPgiYqkxb+ayI4m7UFMAvoUa80 86ogymXbGDlG8ICqA4A== X-Received: from edrd8.prod.google.com ([2002:aa7:d688:0:b0:660:cd0d:914e]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6402:27ce:b0:663:8841:17c9 with SMTP id 4fb4d7f45d1cf-663babc44ecmr8734757a12.10.1773730340157; Mon, 16 Mar 2026 23:52:20 -0700 (PDT) Date: Tue, 17 Mar 2026 06:52:19 +0000 In-Reply-To: <20260303162314.94363-5-dakr@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260303162314.94363-1-dakr@kernel.org> <20260303162314.94363-5-dakr@kernel.org> Message-ID: Subject: Re: [PATCH 4/8] rust: dma: introduce dma::CoherentInit for memory initialization From: Alice Ryhl To: Danilo Krummrich Cc: acourbot@nvidia.com, ojeda@kernel.org, boqun@kernel.org, gary@garyguo.net, bjorn3_gh@protonmail.com, lossin@kernel.org, a.hindborg@kernel.org, tmgross@umich.edu, abdiel.janulgue@gmail.com, daniel.almeida@collabora.com, robin.murphy@arm.com, driver-core@lists.linux.dev, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" On Tue, Mar 03, 2026 at 05:22:55PM +0100, Danilo Krummrich wrote: > Currently, dma::Coherent cannot safely provide (mutable) access to its > underlying memory because the memory might be concurrently accessed by a > DMA device. This makes it difficult to safely initialize the memory > before handing it over to the hardware. > > Introduce dma::CoherentInit, a type that encapsulates a dma::Coherent > before its DMA address is exposed to the device. dma::CoherentInit can > guarantee exclusive access to the inner dma::Coherent and implement > Deref and DerefMut. > > Once the memory is properly initialized, dma::CoherentInit can be > converted into a regular dma::Coherent. > > Signed-off-by: Danilo Krummrich overall LGTM Reviewed-by: Alice Ryhl > + let ptr = core::ptr::from_mut(&mut self[i]); &raw mut self[i]. Alice