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.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 509823A5E65 for ; Tue, 21 Apr 2026 23:43:04 +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=1776814985; cv=none; b=MZ8iIpI3UfYETmsL4WyjZY0A/DtNPl8o3q5ZyAD+E5WNF8nUvz8KDc6czXdiMpWggHTpOU9S0A/MFaUiOuRE9Cb1eB1XSA0ulTBZ0pmuwUxwQpWYErBbCnQeK0vsGGMMvenJbe87tnXN4Cfs7yy6ZyXOueDPPr8+2FqTVUv2l3w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776814985; c=relaxed/simple; bh=7eoUOSwwGtrXzQvYBYAgVNCc7FdT1uM02itEVpiqoHo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=UNVKhMBUnVBDbUBAF4in8Ro4gNrd3tLkoMF+5rCDsLRXJ1iwZLt+xznx+KSTR33e7//di8oAfUr1JGLUaYSM0FHO4pJMERyNcRf6nFaWQ11p/xYFPGgO9kxpyH9ZF3RVk6E6BP0yzTNdcX7h7CrRr+jch+Wdx5//ZquWkMIGYQ4= 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=NuABiLr4; 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="NuABiLr4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776814983; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jUJoaX13jdWIu45OjLeDEbOktd/ZqhMBliQGf0/hzm0=; b=NuABiLr47qBDFXK7H5Ei3e9B4bTQwFw/Tdpney55mcTthxiMY0SZOsn2rs9QrfKuF/LWOO x66gJ5AZpklyTeFRzCe0qcLSdvvLWZ9j5VUdzyVdS7GLkeTEsWKFybBBb1rlRfM+6JDUJw ooB+TjtsV93RypeNXfxNhd/f7OwH8r8= 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-215-F01FVtCJOoO8pRpzXhg6vw-1; Tue, 21 Apr 2026 19:42:59 -0400 X-MC-Unique: F01FVtCJOoO8pRpzXhg6vw-1 X-Mimecast-MFC-AGG-ID: F01FVtCJOoO8pRpzXhg6vw_1776814976 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 6E1221800366; Tue, 21 Apr 2026 23:42:56 +0000 (UTC) Received: from GoldenWind.lan (unknown [10.22.80.14]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E959F180045E; Tue, 21 Apr 2026 23:42:52 +0000 (UTC) From: Lyude Paul To: nouveau@lists.freedesktop.org, Gary Guo , Daniel Almeida , rust-for-linux@vger.kernel.org, Danilo Krummrich , dri-devel@lists.freedesktop.org Cc: Matthew Maurer , FUJITA Tomonori , Lorenzo Stoakes , christian.koenig@amd.com, Asahi Lina , Miguel Ojeda , Andreas Hindborg , Simona Vetter , Alice Ryhl , Boqun Feng , Sumit Semwal , Krishna Ketan Rai , linux-media@vger.kernel.org, Shankari Anand , David Airlie , Benno Lossin , Viresh Kumar , linaro-mm-sig@lists.linaro.org, Asahi Lina , Greg Kroah-Hartman , kernel@vger.kernel.org Subject: [PATCH v11 3/5] drm/gem/shmem: Export drm_gem_shmem_get_pages_sgt_locked() Date: Tue, 21 Apr 2026 19:40:39 -0400 Message-ID: <20260421234234.638503-4-lyude@redhat.com> In-Reply-To: <20260421234234.638503-1-lyude@redhat.com> References: <20260421234234.638503-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 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-MFC-PROC-ID: L6DuVUYvHw-7TKxzGpuZXAhloHQc8ATobbYFmQW-onE_1776814976 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true We will need this for implementing a set of SGTable bindings in Rust for gem shmem objects, so that we can use the dma_resv lock to protect additional resources in the shmem object. Signed-off-by: Lyude Paul Reviewed-by: Alexandre Courbot --- drivers/gpu/drm/drm_gem_shmem_helper.c | 16 +++++++++++++++- include/drm/drm_gem_shmem_helper.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c index d2c34a0e573a1..8003ede197eba 100644 --- a/drivers/gpu/drm/drm_gem_shmem_helper.c +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c @@ -786,12 +786,25 @@ struct sg_table *drm_gem_shmem_get_sg_table(struct drm_gem_shmem_object *shmem) } EXPORT_SYMBOL_GPL(drm_gem_shmem_get_sg_table); -static struct sg_table *drm_gem_shmem_get_pages_sgt_locked(struct drm_gem_shmem_object *shmem) +/** + * drm_gem_shmem_get_pages_sgt_locked - Under dma_resv lock, provide a scatter/gather table of + * pinned pages for an shmem GEM object. + * @shmem: shmem GEM object + * + * This function is the same as drm_gem_shmem_get_pages_sgt, except that the caller is expected to + * already hold the dma_resv lock for @shmem. + * + * Returns: + * A pointer to the scatter/gather table of pinned pages, or error pointer on failure. + */ +struct sg_table *drm_gem_shmem_get_pages_sgt_locked(struct drm_gem_shmem_object *shmem) { struct drm_gem_object *obj = &shmem->base; int ret; struct sg_table *sgt; + dma_resv_assert_held(shmem->base.resv); + if (shmem->sgt) return shmem->sgt; @@ -822,6 +835,7 @@ static struct sg_table *drm_gem_shmem_get_pages_sgt_locked(struct drm_gem_shmem_ drm_gem_shmem_put_pages_locked(shmem); return ERR_PTR(ret); } +EXPORT_SYMBOL_GPL(drm_gem_shmem_get_pages_sgt_locked); /** * drm_gem_shmem_get_pages_sgt - Pin pages, dma map them, and return a diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h index b2c23af628e1a..682207ce9d1b5 100644 --- a/include/drm/drm_gem_shmem_helper.h +++ b/include/drm/drm_gem_shmem_helper.h @@ -138,6 +138,7 @@ void drm_gem_shmem_purge_locked(struct drm_gem_shmem_object *shmem); struct sg_table *drm_gem_shmem_get_sg_table(struct drm_gem_shmem_object *shmem); struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_shmem_object *shmem); +struct sg_table *drm_gem_shmem_get_pages_sgt_locked(struct drm_gem_shmem_object *shmem); void drm_gem_shmem_print_info(const struct drm_gem_shmem_object *shmem, struct drm_printer *p, unsigned int indent); -- 2.53.0