Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp320181rdb; Fri, 5 Jan 2024 10:52:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IFKOioxK4shcjzmQJsnyPlXH2x4w8TL+SlfXlR4hHTZaZKw2Kx6y2Hrz3wczb0kosSx7OtJ X-Received: by 2002:ac8:5a51:0:b0:419:a2c6:820e with SMTP id o17-20020ac85a51000000b00419a2c6820emr3084989qta.12.1704480722286; Fri, 05 Jan 2024 10:52:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704480722; cv=none; d=google.com; s=arc-20160816; b=FQsp+JgBxRMmqSL8CeU89VrCe5HR7iGUEGyb8f6OfJCC8YD1m0RfUSU6t30OMb5LiF G/E5r9NjJvloOk9/4Fl7b2N/MBEYvmGut3BrvzvwpXGSPB1wbg6IUSpDUCxViA0PaJXX 5xXhTRS1FxhvOEgex63VqKcohXAbMALlhvePmU7n3zFUef3QzUWE0+bOjUDQLbcdQBTw Ey7iWzZUCMwf5eYzzcu8WgFjkGyuMF3Mev6qXU/TgjaMtuMmcSmUF5Lx6CYJLeHBZd2L r4x+2ly3eFxqB627oIbw7NkFwpB5HAOZ1/DxT8kIlUBf+t89tlXquyrmcADl0LaYYbqP 4K5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=fGzdvafTKnkzBKiSEmiwdp9/G7aUGCBsu0iw2MRdkyo=; fh=5cel2jD5h+yPMXVwxbomyVhwojHUqATy6nFjd4aOh4o=; b=L2thO8i/k1JasnKE5DlAer8Ko9MNOZ4c52/BdLrQQQ2SJeXxAPZXonBSzSjl4Ypugc tNhYlkt3qWw1Gj3HyTmzk/KQH9R+OcIl+3USa2+gfzVSnU5s4zIaLcRsEROTrSpXvWlX 9Tq9zgd7UCwqamshCEURbGoQ8N/PrNb1a5zs65ZZD98pKpMr8L3D9nnt0xlVyrdoMLTV 1hgpfs+NdMCnQPTQOdza0TA1x59y0jAwdtYWy9CB758QlcXskhoFh31Jy9XOuDVp6Da2 oEdI7EIHIAdQ/BD4S0ZIlGPRPtucPtMWX4Q8gjxEx4v1/2H39dOxPoiS1/AjDhSdpzDi geig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=miPaG4Hu; spf=pass (google.com: domain of linux-kernel+bounces-18258-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18258-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o4-20020ac85a44000000b0042810b9369asi2331977qta.698.2024.01.05.10.52.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 10:52:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18258-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=miPaG4Hu; spf=pass (google.com: domain of linux-kernel+bounces-18258-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18258-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D84571C23B16 for ; Fri, 5 Jan 2024 18:52:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 300B43A1D2; Fri, 5 Jan 2024 18:47:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="miPaG4Hu" X-Original-To: linux-kernel@vger.kernel.org Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (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 2496F3A1A5 for ; Fri, 5 Jan 2024 18:47:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com 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=20K=C3=B6nig?= , Qiang Yu , Steven Price , Boris Brezillon , Emma Anholt , Melissa Wen Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel@collabora.com, virtualization@lists.linux-foundation.org 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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); -- 2.43.0