From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2171E606A32C for ; Thu, 3 Dec 2026 10:32:11 +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: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1C37910E63E; Thu, 3 Dec 2026 10:32:05 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1FDA410E63E for ; Thu, 3 Dec 2026 10:31:59 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id B60214106F; Thu, 3 Dec 2026 10:31:58 +0000 (UTC) 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 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-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: 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