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 D07372DF6F5 for ; Thu, 16 Oct 2025 21:10:37 +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=1760649039; cv=none; b=BwMNs1gpFwfxX5GXLRaRLBtmvG2tgMRLTnv8ZGQc0QRTfNZXuM3RFVnvosutul7f3qMvIisKl5sS8sy+WjTEaM8fJuqEepFzY1g52mByPK+/XW0wxXHc300D3aAgnBoW8oZbxBTx8uH7QcYJuwNRPnjl+mDE1r9Wvm3bpr3dJ+s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760649039; c=relaxed/simple; bh=VFeD61n4EB0IqBO8aUgLNP7Qxxt0T9l60dtbtB72CUo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bcZg6OxyjsK3E5EV/B45zE48KiaFMI+MZFJ/uTd/iaA3cuu1zSNpZ319QJoyUVNM3t1cztwYt6zEavb8p37LB0lQ6rhh/12gOmnz3sYGmNA955vwsldLFw0IFrXVm2JoHvMouIt5YQ8CXXXPRnc4eawgA4sYBB9L0zwF2tCfIdk= 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=YZYRoczI; 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="YZYRoczI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760649036; 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=9ndxGIWx/ZNHEkFTFx03hLRsmSb6lYoWq21ZuRayGVk=; b=YZYRoczIL228rka6x4SMtbCxT5zugCERfXuEOpwok7pdeEHc2RN+qw4fQbRPXUVW0+vOu6 T/j9AmEWqPgJrxO+hOX1q2xPLZEJh7tF5M2wuujQw3qqVonVtWf3zgysmj6ARcEebObE/c 74Z2xUaxJJ46dz5nY2dEsjWd63p940E= Received: from mx-prod-mc-08.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-534-Mnb5-NH5OpK46Iw89vDsDw-1; Thu, 16 Oct 2025 17:10:32 -0400 X-MC-Unique: Mnb5-NH5OpK46Iw89vDsDw-1 X-Mimecast-MFC-AGG-ID: Mnb5-NH5OpK46Iw89vDsDw_1760649028 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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5D1A118001E9; Thu, 16 Oct 2025 21:10:28 +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 E9E68300019F; Thu, 16 Oct 2025 21:10:24 +0000 (UTC) From: Lyude Paul To: dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org, Daniel Almeida , Alice Ryhl Cc: David Airlie , Simona Vetter , Danilo Krummrich , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Trevor Gross , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= , Asahi Lina , Shankari Anand , linux-kernel@vger.kernel.org (open list), linux-media@vger.kernel.org (open list:DMA BUFFER SHARING FRAMEWORK:Keyword:\bdma_(?:buf|fence|resv)\b), linaro-mm-sig@lists.linaro.org (moderated list:DMA BUFFER SHARING FRAMEWORK:Keyword:\bdma_(?:buf|fence|resv)\b) Subject: [PATCH v4 4/9] rust: drm: gem: Add raw_dma_resv() function Date: Thu, 16 Oct 2025 17:08:17 -0400 Message-ID: <20251016210955.2813186-5-lyude@redhat.com> In-Reply-To: <20251016210955.2813186-1-lyude@redhat.com> References: <20251016210955.2813186-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: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 For retrieving a pointer to the struct dma_resv for a given GEM object. We also introduce it in a new trait, BaseObjectPrivate, which we automatically implement for all gem objects and don't expose to users outside of the crate. Signed-off-by: Lyude Paul --- rust/kernel/drm/gem/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs index 981fbb931e952..760fcd61da0b7 100644 --- a/rust/kernel/drm/gem/mod.rs +++ b/rust/kernel/drm/gem/mod.rs @@ -199,6 +199,18 @@ fn create_mmap_offset(&self) -> Result { impl BaseObject for T {} +/// Crate-private base operations shared by all GEM object classes. +#[expect(unused)] +pub(crate) trait BaseObjectPrivate: IntoGEMObject { + /// Return a pointer to this object's dma_resv. + fn raw_dma_resv(&self) -> *mut bindings::dma_resv { + // SAFETY: `as_gem_obj()` always returns a valid pointer to the base DRM gem object + unsafe { (*self.as_raw()).resv } + } +} + +impl BaseObjectPrivate for T {} + /// A base GEM object. /// /// Invariants -- 2.51.0