From nobody Mon Feb 9 21:19:02 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39D1B311959 for ; Fri, 6 Feb 2026 22:35:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770417336; cv=none; b=MTWl3ZPJ4cl5NftYRcBew7qujIQf8mNa3V7DWAkLlMpADp+Po3vOTzrElzvlMfJs41L19kGBHZ+z4pk2BKixPfMYHSAtnWKboK6gWsJ3immbBXdgymnYTajgH7KxLGN0mVt3YhbbyxTNHHskPZejQaygMVCEQzcIT8cZUlt4Muw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770417336; c=relaxed/simple; bh=EWiLw56o2oAZvOESwic91wCfnm+084u+xkfD3e0P20M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XYUzp2tQGksoTTdBIvloRLIVBr6cAN1FjJl8wdFaI+6njyHn4HxyL0jsEEb1C59uIsik1ZafUH3wcTp8Ii3FGV90zLxe53wMwTudcxVKLPfUvkf+oeCHem9NMgWW9QYjtzwrTmEeTces/zPtN4JRxxVF5fmaUMjDSxLhWB+/yco= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Ekw3DqL3; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ekw3DqL3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770417335; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gnS6QBaaX/P+IP6sZlPsB51TH+wxpemSFsKbutcNRhU=; b=Ekw3DqL3d1y701CbFeQgJDOYLO897/PglH3IHA4iQxIvL/BSbn6cK7oUzd/Mm0mYCltxFy VsDGNU8RaCDBsknLr12Ct+ZiEhtlGD18FoFJy6z3CR4e3MOEaEoXYQkPSP9zu2VSSg92Ne IOmVU3WbZGqWRrdsMk1jXpKAmhIayLQ= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-447-tOO4xw6nO3mXd-uRF53sIg-1; Fri, 06 Feb 2026 17:35:34 -0500 X-MC-Unique: tOO4xw6nO3mXd-uRF53sIg-1 X-Mimecast-MFC-AGG-ID: tOO4xw6nO3mXd-uRF53sIg_1770417332 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 528131955F23; Fri, 6 Feb 2026 22:35:32 +0000 (UTC) Received: from GoldenWind.redhat.com (unknown [10.22.64.226]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AEC46192C7C3; Fri, 6 Feb 2026 22:35:30 +0000 (UTC) From: Lyude Paul To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org, Danilo Krummrich Cc: nouveau@lists.freedesktop.org, Daniel Almeida , Gary Guo , Benno Lossin , Alexandre Courbot , Janne Grunau Subject: [PATCH v7 3/7] rust: gem: Introduce DriverObject::Args Date: Fri, 6 Feb 2026 17:34:27 -0500 Message-ID: <20260206223431.693765-4-lyude@redhat.com> In-Reply-To: <20260206223431.693765-1-lyude@redhat.com> References: <20260206223431.693765-1-lyude@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" This is an associated type that may be used in order to specify a data-type to pass to gem objects when construction them, allowing for drivers to more easily initialize their private-data for gem objects. Signed-off-by: Lyude Paul Reviewed-by: Alice Ryhl Reviewed-by: Daniel Almeida Reviewed-by: Janne Grunau --- V3: * s/BaseDriverObject/DriverObject/ V4: * Fix leftover reference to BaseObjectDriver in rustdoc for DriverObject::Args V6: * Fix build errors in Tyr drivers/gpu/drm/nova/gem.rs | 5 +++-- drivers/gpu/drm/tyr/gem.rs | 3 ++- rust/kernel/drm/gem/mod.rs | 13 ++++++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/nova/gem.rs b/drivers/gpu/drm/nova/gem.rs index 2760ba4f3450b..173077eeb2def 100644 --- a/drivers/gpu/drm/nova/gem.rs +++ b/drivers/gpu/drm/nova/gem.rs @@ -18,8 +18,9 @@ pub(crate) struct NovaObject {} =20 impl gem::DriverObject for NovaObject { type Driver =3D NovaDriver; + type Args =3D (); =20 - fn new(_dev: &NovaDevice, _size: usize) -> impl PinInit { + fn new(_dev: &NovaDevice, _size: usize, _args: Self::Args) -> impl Pin= Init { try_pin_init!(NovaObject {}) } } @@ -33,7 +34,7 @@ pub(crate) fn new(dev: &NovaDevice, size: usize) -> Resul= t impl PinInit { + fn new(_dev: &TyrDevice, _size: usize, _args: ()) -> impl PinInit { try_pin_init!(TyrObject {}) } } diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs index 82b3151e5ae3b..972d50d4342dd 100644 --- a/rust/kernel/drm/gem/mod.rs +++ b/rust/kernel/drm/gem/mod.rs @@ -62,8 +62,15 @@ pub trait DriverObject: Sync + Send + Sized { /// Parent `Driver` for this object. type Driver: drm::Driver; =20 + /// The data type to use for passing arguments to [`DriverObject::new`= ]. + type Args; + /// Create a new driver data object for a GEM object of a given size. - fn new(dev: &drm::Device, size: usize) -> impl PinInit; + fn new( + dev: &drm::Device, + size: usize, + args: Self::Args, + ) -> impl PinInit; =20 /// Open a new handle to an existing object, associated with a File. fn open(_obj: &::Object, _file: &DriverFi= le) -> Result { @@ -242,11 +249,11 @@ impl Object { }; =20 /// Create a new GEM object. - pub fn new(dev: &drm::Device, size: usize) -> Result> { + pub fn new(dev: &drm::Device, size: usize, args: T::Args) -= > Result> { let obj: Pin> =3D KBox::pin_init( try_pin_init!(Self { obj: Opaque::new(bindings::drm_gem_object::default()), - data <- T::new(dev, size), + data <- T::new(dev, size, args), }), GFP_KERNEL, )?; --=20 2.53.0