From patchwork Sun Oct 29 23:02:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 13439929 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 ACE47C4167B for ; Sun, 29 Oct 2023 23:03:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E7B5D10E1DA; Sun, 29 Oct 2023 23:03:09 +0000 (UTC) Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5B65610E1D9 for ; Sun, 29 Oct 2023 23:02:59 +0000 (UTC) Received: from workpc.. (109-252-153-31.dynamic.spd-mgts.ru [109.252.153.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dmitry.osipenko) by madras.collabora.co.uk (Postfix) with ESMTPSA id D51C766073AE; Sun, 29 Oct 2023 23:02:56 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1698620578; bh=wqGvYp+XsBubezC7g24J4y9IRLkJRkmLc/LBzEkyYBg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WOwYdYKjt/I83fqDDsTMg5Buu1wHFIkeuyU9wAcSaZy3NfTy6QueCldxukReDXMo3 KBPvD83s9Glkx/p+53DWqpsQHJm+S0ci8yNyxTwamtrjRvAFIQz0FU6NOPJe6sJzsb cSuipy3uuEDuZgiK4toXK1IG6qQBdkNeIGgNjnj57QkEtNdzrsm93/1UBbgpAVAdjX Lot0g4ZFK+tKMsJLbrn+6DzBWbCp0cW9/2Jt5leAiGDM91fUu6C5b4afwkU8AQBY0a YECMj0VIWnka9VVDcHBwwap2dQUuNs2oJc+meDtl3mrAoSYWUeQUhvf8k1DRoHIEI1 jZWv4n6jSLZrw== From: Dmitry Osipenko To: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , =?utf-8?q?Christian_K=C3=B6nig?= , Qiang Yu , Steven Price , Boris Brezillon , Emma Anholt , Melissa Wen Subject: [PATCH v18 21/26] drm/shmem-helper: Optimize unlocked get_pages_sgt() Date: Mon, 30 Oct 2023 02:02:00 +0300 Message-ID: <20231029230205.93277-22-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231029230205.93277-1-dmitry.osipenko@collabora.com> References: <20231029230205.93277-1-dmitry.osipenko@collabora.com> MIME-Version: 1.0 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: , Cc: kernel@collabora.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" SGT isn't refcounted. Once SGT pointer has been obtained, it remains the same for both locked and unlocked get_pages_sgt(). Return cached SGT directly without taking a potentially expensive lock. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c index 560ce565f376..6dd087f19ea3 100644 --- a/drivers/gpu/drm/drm_gem_shmem_helper.c +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c @@ -955,6 +955,9 @@ struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_shmem_object *shmem) drm_WARN_ON(obj->dev, drm_gem_shmem_is_evictable(shmem)); drm_WARN_ON(obj->dev, drm_gem_shmem_is_purgeable(shmem)); + if (shmem->sgt) + return shmem->sgt; + ret = dma_resv_lock_interruptible(shmem->base.resv, NULL); if (ret) return ERR_PTR(ret);