From patchwork Wed Oct 4 10:22:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris BREZILLON X-Patchwork-Id: 9984147 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7BCA56038E for ; Wed, 4 Oct 2017 10:22:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6CBB2287A8 for ; Wed, 4 Oct 2017 10:22:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 61D5328AAF; Wed, 4 Oct 2017 10:22:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2D82B28AB7 for ; Wed, 4 Oct 2017 10:22:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C021689D83; Wed, 4 Oct 2017 10:22:25 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by gabe.freedesktop.org (Postfix) with ESMTP id D25E189B18 for ; Wed, 4 Oct 2017 10:22:24 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 289142092D; Wed, 4 Oct 2017 12:22:23 +0200 (CEST) Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id F19F920923; Wed, 4 Oct 2017 12:22:22 +0200 (CEST) From: Boris Brezillon To: Eric Anholt Date: Wed, 4 Oct 2017 12:22:19 +0200 Message-Id: <20171004102221.23085-2-boris.brezillon@free-electrons.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171004102221.23085-1-boris.brezillon@free-electrons.com> References: <20171004102221.23085-1-boris.brezillon@free-electrons.com> Cc: Intel GFX discussion Subject: [Intel-gfx] [PATCH i-g-t v2 1/3] igt: Add a helper function to mark BOs purgeable X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Boris Brezillon --- Changes in v2: - none --- lib/igt_vc4.c | 12 ++++++++++++ lib/igt_vc4.h | 1 + 2 files changed, 13 insertions(+) diff --git a/lib/igt_vc4.c b/lib/igt_vc4.c index c4682f5688f1..b75c063204ec 100644 --- a/lib/igt_vc4.c +++ b/lib/igt_vc4.c @@ -128,3 +128,15 @@ igt_vc4_mmap_bo(int fd, uint32_t handle, uint32_t size, unsigned prot) else return ptr; } + +bool igt_vc4_purgeable_bo(int fd, int handle, bool purgeable) +{ + struct drm_vc4_gem_madvise arg = { + .handle = handle, + .madv = purgeable ? VC4_MADV_DONTNEED : VC4_MADV_WILLNEED, + }; + + do_ioctl(fd, DRM_IOCTL_VC4_GEM_MADVISE, &arg); + + return arg.retained; +} diff --git a/lib/igt_vc4.h b/lib/igt_vc4.h index e9252461c951..9f0fc59910f6 100644 --- a/lib/igt_vc4.h +++ b/lib/igt_vc4.h @@ -27,5 +27,6 @@ uint32_t igt_vc4_get_cleared_bo(int fd, size_t size, uint32_t clearval); int igt_vc4_create_bo(int fd, size_t size); void *igt_vc4_mmap_bo(int fd, uint32_t handle, uint32_t size, unsigned prot); +bool igt_vc4_purgeable_bo(int fd, int handle, bool purgeable); #endif /* IGT_VC4_H */