From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796293919; b=a8PQLFnGugfXJTtbsbThZ1zdlh+XDEeQaP0yAp8NKX5B0YXj3mHozcJGENTaxPtFNusF v3zmgFa94XDgtVBlbLkikCrMdp4aRRwiFTVvXAAvVk40i98wuqhJAcf5+KQTjQz57yu8G gcmhulk5V0zf4AEvAculpuo+RXFJw5yLwBGS7xrbfBrurxullpRJ5RKk1kG8ftG7sEUWU uHAorcjp261wJvxeSOJp/qNZAWt6QupbhcH8B1xh9pvVoXOBah1eTQB1vpOvkQ0gKlE1g jey/Ubfhwnnw3cai3JK+D9Ic5DLkwYsR//bRlmEwti532+b/UhuovN4fRzYmF79MzYQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796293919; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=0BmvjBYmmDwkfJfrGSeYrAYPWoeGLsZ7y+Xa6q5M4qw=; b=5P34FkoWN8LnCmqTzd5wryD7SSmKsQWlxDzNMGyj7Fv9Lrdcb1syKXog6hNDRQs4dB0S 350kDx6MH+L9mURXb7P1/TCi6MWGJi5gnJl5Zl8w/U7GfZGaCwcwc7qP3Tg7pPVNmdsi1 738ZXkj6lZrJgzktxQYPOMuSQyhrEHnrFaaYmiLrkv/R2kY0eAVnRxr06sqh/yomEimmc m2QEtBKF1ztxYbl00Gm1NMQHTZnRuAz2lPAGjVp7iXjfnXJJjq/32M1kU3+iGeTthaL0M vI3Rqr42qGG39Z21FPEbfR8uasgub1qFqqeXs5LAvffG41bdrM2gXMz8Tj1xD9UFYfg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SBUFYDDE; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CFC1606A32C for ; Thu, 3 Dec 2026 10:31:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SBUFYDDE Received: by smtp.kernel.org (Postfix) with ESMTPSA id A61731F00896; Thu, 3 Dec 2026 10:31:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796293918; bh=0BmvjBYmmDwkfJfrGSeYrAYPWoeGLsZ7y+Xa6q5M4qw=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=SBUFYDDELnkoHqo2Rr37ziBrqsXo1iqKAWVbGdP0f3Iem8JO4tqQZR+E2H1X5T7lg /HYTi7GOsCxrfHvbDGnjpao+041WEUvJfyDDeWWTnjpMr1GHiDd9XSMdmZJmuM4fVU Mi+AsK12nbIDi01gCThS4+r+T0GC70q1ahIqXU2f1jGq5yxfGWJiQO0VFq1v7UpkXu a+eYfs4XIe/G+lbIGjy4x2YpPN+A5ekke2zEqrFdmspSg5kwF12CU1G5MphGiAKWuk DkB/dyUk7lj/N9mfRg4Cs9ZVx81e7ckfA/JWLz7MRLsGOxAFlsuCVKqO27fC3z0QlA S2Z58ui9LNYjg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 3/5] rust: drm: gem: shmem: Implement prime_import_sg_table callback Reply-To: sashiko-reviews@lists.linux.dev To: "Janne Grunau" , "Miguel Ojeda" , "Boqun Feng" , "Gary Guo" , =?utf-8?b?Qmo=?= =?utf-8?b?w7ZybiBSb3kgQmFyb24=?= , "Benno Lossin" , "Andreas Hindborg" , "Alice Ryhl" , "Trevor Gross" , "Danilo Krummrich" , "Daniel Almeida" , "Tamir Duberstein" , "Alexandre Courbot" , =?utf-8?b?T251ciDDlnprYW4=?= , "David Airlie" , "Simona Vetter" , "Sami Tolvanen" , "Lyude Paul" , "Maarten Lankhorst" , "Maxime Ripard" , "Thomas Zimmermann" Cc: dri-devel@lists.freedesktop.org, nova-gpu@lists.linux.dev, stable+noautosel@kernel.org, "Deborah Brouwer" In-Reply-To: <20261203-rust-drm-gem-shmem-imported-sgt-v3-3-8ca393e83e20@jannau.net> References: <20261203-rust-drm-gem-shmem-imported-sgt-v3-0-8ca393e83e20@jannau.net> <20261203-rust-drm-gem-shmem-imported-sgt-v3-3-8ca393e83e20@jannau.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 10:31:50 +0000 X-Mailing-List: nova-gpu@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] rust: drm: shmem: no INVARIANT comment in prime_import_sg_table_callback() -- commit 3732704b088a1bef031019801b36e225d905f2b8 Author: Janne Grunau rust: drm: gem: shmem: Implement prime_import_sg_table callback This commit implements the gem_prime_import_sg_table callback in Rust for DRM shmem GEM objects so Object is allocated and destroyed in Rust rather than C. It also adds DriverObject::create_imported() and implements it for Nova, Tyr, and the shmem KUnit test driver. Link: https://lore.kernel.org/rust-for-linux/20261118114102.490384-1-alicer= yhl@google.com/ [1] > diff --git a/rust/kernel/drm/gem/shmem.rs b/rust/kernel/drm/gem/shmem.rs > index 264ab188f77d4..d6977673e21a9 100644 > --- a/rust/kernel/drm/gem/shmem.rs > +++ b/rust/kernel/drm/gem/shmem.rs [ ... ] > @@ -345,6 +346,67 @@ pub fn new( > Ok(obj) > } > =20 > + /// Create a new shmem GEM object from another driver's scatter/gath= er table of pinned pages. > + /// > + /// This is a Rust re-implemetation of `drm_gem_shmem_prime_import_s= g_table()` to avoid > + /// creating and destroying `Self` in C code. > + /// This function imports a scatter/gather table exported via DMA-BU= F by another driver. > + /// It should be only called via the &drm_driver.gem_prime_import_sg= _table callback. > + extern "C" fn prime_import_sg_table_callback( > + raw_dev: *mut bindings::drm_device, > + raw_attach: *mut bindings::dma_buf_attachment, > + raw_sgt: *mut bindings::sg_table, > + ) -> *mut bindings::drm_gem_object { [ ... ] > + let new: Pin> =3D match KBox::try_pin_init( > + try_pin_init!(Self { > + obj <- Opaque::init_zeroed(), > + parent_resv_obj: None, > + sgt_res: ManuallyDrop::new(SetOnce::new()), > + sgt_lock <- new_mutex!(()), > + inner <- T::create_imported(dev, size), > + }), > + GFP_KERNEL, > + ) { > + Ok(new) =3D> new, > + Err(e) =3D> return e.to_ptr(), > + }; > + > + // SAFETY: `new.as_raw()` is guaranteed to be valid by the initi= alization above. > + unsafe { (*new.as_raw()).funcs =3D &Self::VTABLE }; > + > + // SAFETY: The arguments are all valid via the type invariants. > + if let Err(e) =3D to_result(unsafe { > + bindings::drm_gem_shmem_init(dev.as_raw(), new.as_raw_shmem(= ), size, true) > + }) { > + return e.to_ptr(); > + }; [Severity: Low] Should this try_pin_init!(Self { ... }) carry an // INVARIANT: comment? shmem::Object documents an Invariants section requiring obj to hold a valid initialized struct drm_gem_shmem_object for its lifetime. Per kernel Rust coding guidelines, constructing it should explain why that invariant holds once drm_gem_shmem_init() succeeds before exposing the object. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203-rust-drm-g= em-shmem-imported-sgt-v3-0-8ca393e83e20@jannau.net?part=3D3