From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 599F2F94CB7 for ; Tue, 21 Apr 2026 23:54:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BB32A10EE08; Tue, 21 Apr 2026 23:54:18 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="Ixvdp74j"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id F108410E94E for ; Tue, 21 Apr 2026 23:54:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776815656; 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=Ixvdp74jGxo45NOjVXkAkfAOqA58VxHcrw8e5Y9W+WRpsBRtzcc+3LT+JR8d6IWYUvt/B2 EoWxopsdqmsoHqPxBG0gTIEkp0LA01zT0/EzMN4ZBK5ByP9L9B6VwfMczCEWUhwvrRhf3E fJBzRCIMP+4//P0RghL3EXcEBa1c5wo= 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> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-MFC-PROC-ID: DFWzE1La4_EDTn01L2H3RCMMEbbodyw2Bl_QI5OxIVU_1776815649 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 61E2BF94CB8 for ; Tue, 21 Apr 2026 23:54:20 +0000 (UTC) Received: from kara.freedesktop.org (unknown [131.252.210.166]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0658210EDFA; Tue, 21 Apr 2026 23:54:20 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="Ixvdp74j"; dkim-atps=neutral Received: from kara.freedesktop.org (localhost [127.0.0.1]) by kara.freedesktop.org (Postfix) with ESMTP id 53B6845ABB; Tue, 21 Apr 2026 23:42:12 +0000 (UTC) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=lists.freedesktop.org; s=20240201; t=1776814932; b=ZW8RGM7gW4532uo5jm59KlRp9QaFhGJFs9L5ixHM1QNhRUDTp0bHBHtboYQVI1a4DHScx 86sX1mLX3UW7QPoNHVodbno6KqiLsxmOZ+oGnCMgU9ChsF8CdSE63mbYxhAda6eGZoJPv/x 8Eugcz5+fAejte6yhsXt5BNYuLaCCfO/2NdlW0vtJ5kYWplDhpi6yASEhouvCkPZrwfB9/y aXd/6YShmcRk9SXU/459sYyHfYoDZiIlyVr7KNeK+JsSK+kIx4qB4BOokdpZNrTMs4ote1T aQAz1o61FSlfQ4M4cI33IFLYEgDyMG79AuyJuKO7YwOtnKfNpaC90LESEqNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.freedesktop.org; s=20240201; t=1776814932; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=jUJoaX13jdWIu45OjLeDEbOktd/ZqhMBliQGf0/hzm0=; b=HwI0NKW07lfkwQtA5N9VXf9qaPsJSHVY4zTvdBU03hIv/8u+BkINOWq9QwJSOArYL/SWp 9rN15C5MHBfYRueDvi5yeJi/w1OXMSTc0ltNu5SD4PwhS+wDsiUnkH0neHEpJLrMuAY8AVC GQEYigAl7XRdEjMWZYx2FpUdzn3I5WeG+iJM0H3jv4ud7qxTgzOc0yBcJQpYF2aGFcFdOjw XWnTxtHXQjIcUf1RfYidU9pHiMVGI0bSk8XhFxjUxI4FvJMrrDd96xIrKmHLqFCyOr7oy/L ZoLMywgUyhIaNczYfjm9EzPqLe8xpjA4zq3KB+/wGAU0M2XF4gXGB9atju1w== ARC-Authentication-Results: i=1; mail.freedesktop.org; dkim=pass header.d=redhat.com; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=redhat.com policy.dmarc=quarantine Authentication-Results: mail.freedesktop.org; dkim=pass header.d=redhat.com; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=redhat.com policy.dmarc=quarantine Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by kara.freedesktop.org (Postfix) with ESMTPS id 9795B45A9A for ; Tue, 21 Apr 2026 23:42:09 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id F375D10EDF1 for ; Tue, 21 Apr 2026 23:54:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776815656; 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=Ixvdp74jGxo45NOjVXkAkfAOqA58VxHcrw8e5Y9W+WRpsBRtzcc+3LT+JR8d6IWYUvt/B2 EoWxopsdqmsoHqPxBG0gTIEkp0LA01zT0/EzMN4ZBK5ByP9L9B6VwfMczCEWUhwvrRhf3E fJBzRCIMP+4//P0RghL3EXcEBa1c5wo= 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 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> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-MFC-PROC-ID: L4h3gPKZsLHy2lUjMCXg9FEYrTW7u3oI1x79Wv21EuM_1776815649 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: X7S4FS6KOGTKRF4XSEOFEVLXWR3O2DMC X-Message-ID-Hash: X7S4FS6KOGTKRF4XSEOFEVLXWR3O2DMC X-MailFrom: lyude@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header 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 , Benno Lossin , Viresh Kumar , linaro-mm-sig@lists.linaro.org, Asahi Lina , Greg Kroah-Hartman , kernel@vger.kernel.org X-Mailman-Version: 3.3.8 Precedence: list List-Id: Nouveau development list Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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