From patchwork Wed Jul 18 10:56:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10532113 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 D0BA06020A for ; Wed, 18 Jul 2018 10:56:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC1C028FA9 for ; Wed, 18 Jul 2018 10:56:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0AF828FBB; Wed, 18 Jul 2018 10:56:40 +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=-5.2 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, 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 62CE928FA9 for ; Wed, 18 Jul 2018 10:56:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8078D6EAC0; Wed, 18 Jul 2018 10:56:39 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1FD1F6E24E; Wed, 18 Jul 2018 10:56:36 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 12388474-1500050 for multiple; Wed, 18 Jul 2018 11:56:26 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Wed, 18 Jul 2018 11:56:27 +0100 Message-Id: <20180718105627.27023-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t] lib: Move trash_bos to their only user X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Only pm_rpm still uses the igt_trash_aperture() and so we can remove it from the lib and in the process convert it over from the legacy libdrm_intel. Signed-off-by: Chris Wilson Cc: Michał Winiarski Reviewed-by: Michał Winiarski --- lib/igt_aux.c | 57 -------------------------------------------------- lib/igt_aux.h | 10 +-------- tests/pm_rpm.c | 31 ++++++++++++++++++--------- 3 files changed, 22 insertions(+), 76 deletions(-) diff --git a/lib/igt_aux.c b/lib/igt_aux.c index d9dbf7ced..1250d5c5f 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -682,63 +682,6 @@ void igt_print_activity(void) igt_interactive_info("."); } -/* mappable aperture trasher helper */ -drm_intel_bo **trash_bos; -int num_trash_bos; - -/** - * igt_init_aperture_trashers: - * @bufmgr: libdrm buffer manager - * - * Initialize the aperture trasher using @bufmgr, which can then be run with - * igt_trash_aperture(). - */ -void igt_init_aperture_trashers(drm_intel_bufmgr *bufmgr) -{ - int i; - - num_trash_bos = gem_mappable_aperture_size() / (1024*1024); - - trash_bos = malloc(num_trash_bos * sizeof(drm_intel_bo *)); - igt_assert(trash_bos); - - for (i = 0; i < num_trash_bos; i++) - trash_bos[i] = drm_intel_bo_alloc(bufmgr, "trash bo", 1024*1024, 4096); -} - -/** - * igt_trash_aperture: - * - * Trash the aperture by walking a set of GTT memory mapped objects. - */ -void igt_trash_aperture(void) -{ - int i; - uint8_t *gtt_ptr; - - for (i = 0; i < num_trash_bos; i++) { - drm_intel_gem_bo_map_gtt(trash_bos[i]); - gtt_ptr = trash_bos[i]->virtual; - *gtt_ptr = 0; - drm_intel_gem_bo_unmap_gtt(trash_bos[i]); - } -} - -/** - * igt_cleanup_aperture_trashers: - * - * Clean up all aperture trasher state set up with igt_init_aperture_trashers(). - */ -void igt_cleanup_aperture_trashers(void) -{ - int i; - - for (i = 0; i < num_trash_bos; i++) - drm_intel_bo_unreference(trash_bos[i]); - - free(trash_bos); -} - static int autoresume_delay; static const char *suspend_state_name[] = { diff --git a/lib/igt_aux.h b/lib/igt_aux.h index 639a90778..ef89faa9b 100644 --- a/lib/igt_aux.h +++ b/lib/igt_aux.h @@ -28,16 +28,13 @@ #ifndef IGT_AUX_H #define IGT_AUX_H -#include #include #include +#include #include #include -extern drm_intel_bo **trash_bos; -extern int num_trash_bos; - /* signal interrupt helpers */ #define gettid() syscall(__NR_gettid) #define sigev_notify_thread_id _sigev_un._tid @@ -122,11 +119,6 @@ bool igt_check_boolean_env_var(const char *env_var, bool default_value); bool igt_aub_dump_enabled(void); -/* helpers based upon the libdrm buffer manager */ -void igt_init_aperture_trashers(drm_intel_bufmgr *bufmgr); -void igt_trash_aperture(void); -void igt_cleanup_aperture_trashers(void); - /* suspend/hibernate and auto-resume system */ /** diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c index 1f2647be1..4268bb19a 100644 --- a/tests/pm_rpm.c +++ b/tests/pm_rpm.c @@ -1295,25 +1295,36 @@ static void gem_idle_subtest(void) static void gem_evict_pwrite_subtest(void) { - static drm_intel_bufmgr *bufmgr; + struct { + uint32_t handle; + uint32_t *ptr; + } *trash_bos; + unsigned int num_trash_bos, n; uint32_t buf; - int i; - bufmgr = drm_intel_bufmgr_gem_init(drm_fd, 4096); - igt_assert(bufmgr); - igt_init_aperture_trashers(bufmgr); + num_trash_bos = gem_mappable_aperture_size() / (1024*1024) + 1; + trash_bos = malloc(num_trash_bos * sizeof(*trash_bos)); + igt_assert(trash_bos); - igt_trash_aperture(); + for (n = 0; n < num_trash_bos; n++) { + trash_bos[n].handle = gem_create(drm_fd, 1024*1024); + trash_bos[n].ptr = gem_mmap__gtt(drm_fd, trash_bos[n].handle, + 1024*1024, PROT_WRITE); + *trash_bos[n].ptr = 0; + } disable_or_dpms_all_screens_and_wait(&ms_data, true); igt_assert(wait_for_suspended()); buf = 0; - for (i = 0; i < num_trash_bos; i++) - gem_write(drm_fd, trash_bos[i]->handle, 0, &buf, sizeof(buf)); + for (n = 0; n < num_trash_bos; n++) + gem_write(drm_fd, trash_bos[n].handle, 0, &buf, sizeof(buf)); - igt_cleanup_aperture_trashers(); - drm_intel_bufmgr_destroy(bufmgr); + for (n = 0; n < num_trash_bos; n++) { + munmap(trash_bos[n].ptr, 1024*1024); + gem_close(drm_fd, trash_bos[n].handle); + } + free(trash_bos); } /* This also triggered WARNs on dmesg at some point. */