Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp320115rdb; Fri, 5 Jan 2024 10:51:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IH8cQkG40x1WcOEHh2giqpsZahH5u2CVRfzK+As3HVCrCyYApwtFweMKKkKDzvkunE6/M9m X-Received: by 2002:a05:6a20:7351:b0:199:1c21:48 with SMTP id v17-20020a056a20735100b001991c210048mr2915047pzc.10.1704480710455; Fri, 05 Jan 2024 10:51:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704480710; cv=none; d=google.com; s=arc-20160816; b=ot31K34ROUulih1ppP9U1vpMA47OF76ypqP/cU9PPmBWXFZNp4uKQmK2PRCAcWvbuf wHMWS+SudHa6yLTPQSBhlvY+6y0fSz3636B/7TAaAXbR0rVjVJrwSBqxahZzh2p39UMh nUWhbsRXBii/INV1N9KWyQZFiSynC4NGbt2iLl5Jc2/+blIGqg89jVqlgqTRoL7TzLzt DSnCzKBXAzAapfQymVDtAgPHoLL4Q1HCOppN0kYYQgAxnzgPYmcEbR1fRBxvproSosav yZBnTRdqDZTwuK/JMe30S12kGxkc52L+l7RmJpfmF91unh4hD0RQs3fM3CUkAJLHAKw2 W6mw== 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=8py+TlC4Jl2fSH7FalK2pnflGO/vrChK/B1Ekgowfjc=; fh=5cel2jD5h+yPMXVwxbomyVhwojHUqATy6nFjd4aOh4o=; b=trsVO5AdgyYkZn7enssNjZOBA5GJU5gCO4sAV/gBTJFk+Z89L4aQqpbzIxep6SITKM uSnQ3ai6WeXm6zGY7XMzp8V4vxaRbJQNyYsnVTj45cGFgV2sNHDP+R7Hrkm0c0UsrV6e 5HpU/2gwXdIN38KuxTVVN4O49ok0ZVDxay2vc3aFKBr6WlvEYNXc2tmeTDYZDGisWqDs /mulQ90d0MkP+sb7K1l2/kCUNqiembGJSBZJ5hoo+9FixMew0Rj9ZDDTwlZZwG1eFJdB nobCje3vZDG4c8BFDvv9iFlkRVKHafSk8rPr1IPf/8lPkrdh6D3f1D7wTJDjXGdZ++wP Ol7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=QgOl2UJs; spf=pass (google.com: domain of linux-kernel+bounces-18257-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18257-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id fc17-20020a056a002e1100b006d9ac27675fsi1694506pfb.343.2024.01.05.10.51.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 10:51:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18257-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=QgOl2UJs; spf=pass (google.com: domain of linux-kernel+bounces-18257-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18257-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 1ACCC28665B for ; Fri, 5 Jan 2024 18:51:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AEA7D3A1B1; Fri, 5 Jan 2024 18:47:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="QgOl2UJs" 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 9EFAF39FE4 for ; Fri, 5 Jan 2024 18:47:16 +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=1704480435; bh=YBkVn5jKdYvc4x1kT23ZC29JJbOYH68uDMV2t2TN/6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QgOl2UJs08qDGmwrciCZCNsVoDOox4BtpEAkEHtlwtVBVrIZuNVP8ke8kqwz1D+iq AkWrKDiRFjWApzsL2X/+2iSrDEy++LL4hfhOJb+R9UM7iHnnAjrK8IVR0lDImUZUnl +3pGTpxWS787PSte07Ad+jmiINWOknqI7KiATFYTyOy4vrAua1N9PzA44bP4um745V crV6/5sZa24o5ti+d1DL//yfy3+Ukn7VOkRt/dr0NM+VYPH7OBYwSUZYVD64hmfq8U dN7fcx2Jw29ut3l0oZs6g27aAD49iE2Am2vgdA/wnPfEpSH3Mnxyl+Vy96sYY5H6g4 X1wP/7EUuD0XQ== 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 A5ACB378205F; Fri, 5 Jan 2024 18:47:13 +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 19/30] drm/virtio: Explicitly get and put drm-shmem pages Date: Fri, 5 Jan 2024 21:46:13 +0300 Message-ID: <20240105184624.508603-20-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 We're moving away from implicit get_pages() that is done by get_pages_sgt() to simplify the refcnt handling. Drivers will have to pin pages while they use sgt. VirtIO-GPU 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/virtio/virtgpu_object.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c index c7e74cf13022..e58528c562ef 100644 --- a/drivers/gpu/drm/virtio/virtgpu_object.c +++ b/drivers/gpu/drm/virtio/virtgpu_object.c @@ -67,6 +67,7 @@ void virtio_gpu_cleanup_object(struct virtio_gpu_object *bo) virtio_gpu_resource_id_put(vgdev, bo->hw_res_handle); if (virtio_gpu_is_shmem(bo)) { + drm_gem_shmem_put_pages(&bo->base); drm_gem_shmem_free(&bo->base); } else if (virtio_gpu_is_vram(bo)) { struct virtio_gpu_object_vram *vram = to_virtio_gpu_vram(bo); @@ -196,9 +197,13 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev, return PTR_ERR(shmem_obj); bo = gem_to_virtio_gpu_obj(&shmem_obj->base); + ret = drm_gem_shmem_get_pages(shmem_obj); + if (ret) + goto err_free_gem; + ret = virtio_gpu_resource_id_get(vgdev, &bo->hw_res_handle); if (ret < 0) - goto err_free_gem; + goto err_put_pages; bo->dumb = params->dumb; @@ -243,6 +248,8 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev, kvfree(ents); err_put_id: virtio_gpu_resource_id_put(vgdev, bo->hw_res_handle); +err_put_pages: + drm_gem_shmem_put_pages(shmem_obj); err_free_gem: drm_gem_shmem_free(shmem_obj); return ret; -- 2.43.0