From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 9F7602E2DD8 for ; Thu, 16 Oct 2025 21:10:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760649042; cv=none; b=A9mrfWN+Z51deFyi+9f0u92ZotzGxbDqCeiABPHfHnfx8hrndIte3+10ycPV4mlW721xW/nOIlOF+fygihQpgpwnEZ1VcQObpCpViWFNSMY4VWoF4/BYbqZyi7ECCjCBJgrz63hl8I/OW9KBcocLUPHhFBEgvkRvVh18n3eCskY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760649042; c=relaxed/simple; bh=9UG2qm1ae2+tmfCKymGtvd0GlnpofCIr9dbA0kzjg0E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AMIAH427VFnVjMnKliT/zPYWXUhZx21lNshfQ8o1XJWsYWuSYdmeq8h3hu1Yy/y4xVFSJrgxhihTtlnRJCBC1nwr3sA0Z2K2LmFQnf6kvHrVx19s0L0x1ndet5P7IaLNkdiu7Q+LKK3bQ9271cQ3OKJ2Tf2NhKbdbdhvf+wAD30= 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=T5hiLgBa; arc=none smtp.client-ip=170.10.133.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="T5hiLgBa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760649039; 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=RFGYI2GY+pZyjlwMees9S7niC3kaCabOLOovFrN+Si8=; b=T5hiLgBaKQ4kQcrtZ5iRRH2b59E5BI7b9PYeM8Si1Yi6/xRxcmDoGgqG0tYbfSN0yhxuom lPOBswd+IJ2ysJx4Ho7Fw9tL1qDt8JD58QjgYoHuovmyyD/m1SpTikyZ8bZKdRWUOOwlAr 6FwY1VhT+hA9NQjmdOHyvca1PybKhbQ= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-664-BvqlooD8PCyHmVkNPNnZ4Q-1; Thu, 16 Oct 2025 17:10:36 -0400 X-MC-Unique: BvqlooD8PCyHmVkNPNnZ4Q-1 X-Mimecast-MFC-AGG-ID: BvqlooD8PCyHmVkNPNnZ4Q_1760649034 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 13F5E180122A; Thu, 16 Oct 2025 21:10:34 +0000 (UTC) Received: from chopper.lan (unknown [10.22.80.252]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3206E300019F; Thu, 16 Oct 2025 21:10:31 +0000 (UTC) From: Lyude Paul To: dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org, Daniel Almeida , Alice Ryhl Cc: Danilo Krummrich , David Airlie , Simona Vetter , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Trevor Gross , Asahi Lina , Shankari Anand , nouveau@lists.freedesktop.org (open list:DRM DRIVER FOR NVIDIA GPUS [RUST]), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 5/9] rust: gem: Introduce DriverObject::Args Date: Thu, 16 Oct 2025 17:08:18 -0400 Message-ID: <20251016210955.2813186-6-lyude@redhat.com> In-Reply-To: <20251016210955.2813186-1-lyude@redhat.com> References: <20251016210955.2813186-1-lyude@redhat.com> Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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 --- V3: * s/BaseDriverObject/DriverObject/ V4: * Fix leftover reference to BaseObjectDriver in rustdoc for DriverObject::Args Signed-off-by: Lyude Paul --- drivers/gpu/drm/nova/gem.rs | 5 +++-- rust/kernel/drm/gem/mod.rs | 13 ++++++++++--- 2 files changed, 13 insertions(+), 5 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 {} impl gem::DriverObject for NovaObject { type Driver = NovaDriver; + type Args = (); - fn new(_dev: &NovaDevice, _size: usize) -> impl PinInit { + fn new(_dev: &NovaDevice, _size: usize, _args: Self::Args) -> impl PinInit { try_pin_init!(NovaObject {}) } } @@ -33,7 +34,7 @@ pub(crate) fn new(dev: &NovaDevice, size: usize) -> Result, size: usize) -> impl PinInit; + fn new( + dev: &drm::Device, + size: usize, + args: Self::Args, + ) -> impl PinInit; /// Open a new handle to an existing object, associated with a File. fn open(_obj: &::Object, _file: &DriverFile) -> Result { @@ -246,11 +253,11 @@ impl Object { }; /// 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> = 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), // INVARIANT: The drm subsystem guarantees that the `struct drm_device` will live // as long as the GEM object lives. dev: dev.into(), -- 2.51.0