From patchwork Wed Sep 27 11:51:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris BREZILLON X-Patchwork-Id: 9973853 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 CAB3A602D6 for ; Wed, 27 Sep 2017 11:51:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA05228CDB for ; Wed, 27 Sep 2017 11:51:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF0BE28CE0; Wed, 27 Sep 2017 11:51:36 +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 4E4ED288A0 for ; Wed, 27 Sep 2017 11:51:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 74D0A6E6E6; Wed, 27 Sep 2017 11:51:35 +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 EF15F6E6E9 for ; Wed, 27 Sep 2017 11:51:33 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 845E4208A9; Wed, 27 Sep 2017 13:51:32 +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 53631208A9; Wed, 27 Sep 2017 13:51:21 +0200 (CEST) From: Boris Brezillon To: Intel GFX discussion Date: Wed, 27 Sep 2017 13:51:17 +0200 Message-Id: <20170927115118.23170-2-boris.brezillon@free-electrons.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170927115118.23170-1-boris.brezillon@free-electrons.com> References: <20170927115118.23170-1-boris.brezillon@free-electrons.com> Subject: [Intel-gfx] [PATCH i-g-t 1/2] 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 --- 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 */