From patchwork Tue Dec 5 07:48:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: kevin.rogovin@intel.com X-Patchwork-Id: 10092391 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 2B21760327 for ; Tue, 5 Dec 2017 07:48:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D21B292C4 for ; Tue, 5 Dec 2017 07:48:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11D92294F3; Tue, 5 Dec 2017 07:48:25 +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 C9C5D292C4 for ; Tue, 5 Dec 2017 07:48:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0D4056E40E; Tue, 5 Dec 2017 07:48:24 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2FD6E6E40C for ; Tue, 5 Dec 2017 07:48:23 +0000 (UTC) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Dec 2017 23:48:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,363,1508828400"; d="scan'208";a="181454356" Received: from bdzido-mobl.ger.corp.intel.com (HELO LittleBigTrouble.ger.corp.intel.com) ([10.252.6.207]) by orsmga005.jf.intel.com with ESMTP; 04 Dec 2017 23:48:21 -0800 From: kevin.rogovin@intel.com To: intel-gfx@lists.freedesktop.org Date: Tue, 5 Dec 2017 09:48:14 +0200 Message-Id: <1512460094-4615-4-git-send-email-kevin.rogovin@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512460094-4615-1-git-send-email-kevin.rogovin@intel.com> References: <1512460094-4615-1-git-send-email-kevin.rogovin@intel.com> Cc: Kevin Rogovin Subject: [Intel-gfx] [PATCH 3/3] i965: check scratch page in a locked fashion on each ioctl 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 From: Kevin Rogovin --- src/mesa/drivers/dri/i965/intel_batchbuffer.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c index 216073129b..53b3eaf49b 100644 --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c @@ -804,7 +804,8 @@ static int submit_batch(struct brw_context *brw, int in_fence_fd, int *out_fence_fd) { const struct gen_device_info *devinfo = &brw->screen->devinfo; - __DRIscreen *dri_screen = brw->screen->driScrnPriv; + struct intel_screen *screen = brw->screen; + __DRIscreen *dri_screen = screen->driScrnPriv; struct intel_batchbuffer *batch = &brw->batch; int ret = 0; @@ -875,10 +876,34 @@ submit_batch(struct brw_context *brw, int in_fence_fd, int *out_fence_fd) batch->validation_list[index] = tmp; } + if (unlikely(screen->debug_batchbuffer.enabled)) { + simple_mtx_lock(&screen->debug_batchbuffer.mutex); + } + ret = execbuffer(dri_screen->fd, batch, hw_ctx, 4 * USED_BATCH(*batch), in_fence_fd, out_fence_fd, flags); + if (unlikely(screen->debug_batchbuffer.enabled)) { + struct drm_i915_scratch_page sc; + int ret; + + while (brw_bo_busy(batch->bo)) { + usleep(10); + } + + sc.buffer_size = screen->debug_batchbuffer.buffer_size; + sc.buffer_ptr = (__u64)(uintptr_t) screen->debug_batchbuffer.tmp; + + ret = drmIoctl(dri_screen->fd, DRM_IOCTL_I915_READ_SCRATCH_PAGE, &sc); + assert(ret == 0); + assert(sc.buffer_size == screen->debug_batchbuffer.buffer_size); + assert(memcmp(screen->debug_batchbuffer.tmp, + screen->debug_batchbuffer.noise_values, + screen->debug_batchbuffer.buffer_size) == 0); + simple_mtx_unlock(&screen->debug_batchbuffer.mutex); + } + throttle(brw); }