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 5E6521F5437 for ; Thu, 9 Apr 2026 00:16:31 +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=1775693792; cv=none; b=vCtTnBNjzhAi53anqbkgQuZ0GE0+NdhuVuzxQ2WgYNYZPo68lvKAc2ChDtl2LMMJazuajZolyNxRiK8Z9Kcw4Jvt5egE7waetoP2zjzOKlHhLk5QjTueEJOOfnUASIoM4/+Y8zO6U8aeY1h0o0ICC2Ad1T/Fh29ua9BsZJEQC/k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775693792; c=relaxed/simple; bh=oGvJoS7paCHpuGja+oml8uJIrV99rHOu13DXbLGc7x0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=dOapFmA1YwrnxQ0YH4H+xjgF8DqGge5KL7uQst9H9R/3UE2DyX+0qZBdqx05haxsDCLWRoJf8kYRlet1chvEFdF28DYGek5eFPSD3JqKTp6Yd3cSPJQQF9rbgd8wmHjWqbR97dhu93e4hToLEnjl8CnlRZLTsW2+VZiL5Ty4yKI= 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=D4yqvtMR; 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="D4yqvtMR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775693790; 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=IRHIFNm2rjUvENm+hY1OchiJVsinFnXuSdTKyUKucEM=; b=D4yqvtMRiYkCBgHW+sO2yswYLSn54hJ9J1cGEeVNXDEdOvIGjnB0S1hyc1RFV1YVFvBpwj +W4jxxuCljA/BLfYa/9RDMYZq9VfLBAvpPK700n0ssJyUPHdJJxubVIJ7QTsD88xH7lMT0 zsrs7RNkSNTfMdkItkh7n1vnA4Fv2gA= 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-681-I_p55fOhPruoKIjP00dvZw-1; Wed, 08 Apr 2026 20:16:24 -0400 X-MC-Unique: I_p55fOhPruoKIjP00dvZw-1 X-Mimecast-MFC-AGG-ID: I_p55fOhPruoKIjP00dvZw_1775693781 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 D04EF18005B0; Thu, 9 Apr 2026 00:16:20 +0000 (UTC) Received: from GoldenWind.redhat.com (unknown [10.22.80.49]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3A4C2300019F; Thu, 9 Apr 2026 00:16:17 +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 v10 3/5] drm/gem/shmem: Export drm_gem_shmem_get_pages_sgt_locked() Date: Wed, 8 Apr 2026 20:12:49 -0400 Message-ID: <20260409001559.622026-4-lyude@redhat.com> In-Reply-To: <20260409001559.622026-1-lyude@redhat.com> References: <20260409001559.622026-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.4 X-Mimecast-MFC-PROC-ID: k0pSYtXIrqp6YSVhsgkVjc0HA7iIXNow0KIEF0i-0xc_1775693781 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 --- 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 addf8c1e5341e..15de7f6cc4981 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_sg_table - 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 poitner 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