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 102AF38655B for ; Tue, 21 Apr 2026 23:54:18 +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=1776815660; cv=none; b=Y+jwiqzAfOB+HDpjpkBt/LDpNcLZKhJfAe6o6AfqeoE4n8LSPcmaV1e3nZZAGvD4kAuGFJiTO5hJV9quZ3WJTkvvfdurVjhhuQtPZiF6sK1A1XeIpILEhXDJGuDLjVLCc1joQwzbKUq8XrJaVqpnQ04aTV/6nCEb9OujVdGBfl8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776815660; c=relaxed/simple; bh=7eoUOSwwGtrXzQvYBYAgVNCc7FdT1uM02itEVpiqoHo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=I0fA+Tagdi584CDLKqokFdlrZoOdLHWwqTnWKoV6pe4tYlyMdRmlsM2OCcusJyWidHn6kIRzbCyAZsGtTLsF8AjnPCFTTzLfkbPVx82qpepkR52ExoU2uGr9Jx60EKNLZtaYh9a2Po2oCcYaKcf66yEaonJd/IclIjlSBsjBMMY= 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=KidFy1Af; 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="KidFy1Af" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776815658; 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=KidFy1AfyH3iafEUh0wkCUYmJNgrwg50ZuTm61OMWZKhp++8w8vwgB20gS2x2QExcUveTb Y7ROKKJU6AM9wA/d63Ij1Ty6ZyDKda48biX8idNc6maP7ymmdxlrEPPtwPcPzKagVLJr7/ cma8dZlj4Hp0bOegpaYaO/68glglcVE= Received: from mx-prod-mc-01.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-615-UC4FWpqVOrq1_VOaGXey-A-1; Tue, 21 Apr 2026 19:54:12 -0400 X-MC-Unique: UC4FWpqVOrq1_VOaGXey-A-1 X-Mimecast-MFC-AGG-ID: UC4FWpqVOrq1_VOaGXey-A_1776815649 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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9C8281956095; Tue, 21 Apr 2026 23:54:09 +0000 (UTC) Received: from GoldenWind.lan (unknown [10.22.80.14]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 798F31956095; Tue, 21 Apr 2026 23:54:05 +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 v12 3/5] drm/gem/shmem: Export drm_gem_shmem_get_pages_sgt_locked() Date: Tue, 21 Apr 2026 19:52:15 -0400 Message-ID: <20260421235346.672794-4-lyude@redhat.com> In-Reply-To: <20260421235346.672794-1-lyude@redhat.com> References: <20260421235346.672794-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.0 on 10.30.177.17 X-Mimecast-MFC-PROC-ID: 3USce3B0ELdGcEFE0TojrB1n2vXU8RT8ICHAdZ4aQVc_1776815649 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