From patchwork Fri Jan 5 18:46:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 13512469 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 2AF4DC47077 for ; Fri, 5 Jan 2024 18:47:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3625710E68A; Fri, 5 Jan 2024 18:47:19 +0000 (UTC) Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [IPv6:2a00:1098:ed:100::25]) by gabe.freedesktop.org (Postfix) with ESMTPS id BE1CB10E686 for ; Fri, 5 Jan 2024 18:47:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1704480436; bh=zkWIJ7P9a1m72+FqeXAbXwbM9DM9q7qPsdOCL/PnHw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=miPaG4HuD6TrsZB5vjF09RmNn3Kv/vL8zJWm0NmB4CXk5oPvt/0pLFN+4ug8zAQXr QyIVqu8GNWov925rkVbmgYnI591tXKO8ahE62rh/EQEdcE+3QP03LmNEpSLVNIqpA0 Pa4Iv5g9cd5oVudpHQFKDineB2eId4+6Z6lLG+Dpks0WJx1ISR9IqenNM7/M1VidcG gezJlH6cj3gWqB4Gx67gw71X74QW1RzpBJ/vQyVXjjrTUvQ3NczXrOr4+MaADY0Azh rz1TypBo10P0asqwX4BuZyr6EJ8ZIvEYvmlM0lxrQsoG/Vmg8nK4ZHHrMgggyFKLQQ dRHp1x3enna4A== Received: from workpc.. (cola.collaboradmins.com [195.201.22.229]) (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 madrid.collaboradmins.com (Postfix) with ESMTPSA id 4E4F83782047; Fri, 5 Jan 2024 18:47:15 +0000 (UTC) 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 v19 20/30] drm/v3d: Explicitly get and put drm-shmem pages Date: Fri, 5 Jan 2024 21:46:14 +0300 Message-ID: <20240105184624.508603-21-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240105184624.508603-1-dmitry.osipenko@collabora.com> References: <20240105184624.508603-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" To simplify the drm-shmem refcnt handling, we're moving away from the implicit get_pages() that is used by get_pages_sgt(). From now on drivers will have to pin pages while they use sgt. V3D driver doesn't support shrinker, hence pages are pinned and sgt is valid as long as pages' use-count > 0. Reviewed-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/v3d/v3d_bo.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/v3d/v3d_bo.c b/drivers/gpu/drm/v3d/v3d_bo.c index 1bdfac8beafd..ccf04ce93e8c 100644 --- a/drivers/gpu/drm/v3d/v3d_bo.c +++ b/drivers/gpu/drm/v3d/v3d_bo.c @@ -50,6 +50,9 @@ void v3d_free_object(struct drm_gem_object *obj) /* GPU execution may have dirtied any pages in the BO. */ bo->base.pages_mark_dirty_on_put = true; + if (!obj->import_attach) + drm_gem_shmem_put_pages(&bo->base); + drm_gem_shmem_free(&bo->base); } @@ -139,12 +142,18 @@ struct v3d_bo *v3d_bo_create(struct drm_device *dev, struct drm_file *file_priv, bo = to_v3d_bo(&shmem_obj->base); bo->vaddr = NULL; - ret = v3d_bo_create_finish(&shmem_obj->base); + ret = drm_gem_shmem_get_pages(shmem_obj); if (ret) goto free_obj; + ret = v3d_bo_create_finish(&shmem_obj->base); + if (ret) + goto put_pages; + return bo; +put_pages: + drm_gem_shmem_put_pages(shmem_obj); free_obj: drm_gem_shmem_free(shmem_obj); return ERR_PTR(ret);