From patchwork Sat Mar 11 01:14:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kenneth Graunke X-Patchwork-Id: 9618293 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 BCCF160417 for ; Sat, 11 Mar 2017 01:14:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A32A4287AF for ; Sat, 11 Mar 2017 01:14:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98208287B3; Sat, 11 Mar 2017 01:14:48 +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=-3.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM 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 CA9FE287B6 for ; Sat, 11 Mar 2017 01:14:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 263386E306; Sat, 11 Mar 2017 01:14:44 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from smtp81.iad3a.emailsrvr.com (smtp81.iad3a.emailsrvr.com [173.203.187.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id 16C886E302; Sat, 11 Mar 2017 01:14:42 +0000 (UTC) Received: from smtp11.relay.iad3a.emailsrvr.com (localhost [127.0.0.1]) by smtp11.relay.iad3a.emailsrvr.com (SMTP Server) with ESMTP id 37146531B; Fri, 10 Mar 2017 20:14:41 -0500 (EST) X-Auth-ID: kenneth@whitecape.org Received: by smtp11.relay.iad3a.emailsrvr.com (Authenticated sender: kenneth-AT-whitecape.org) with ESMTPSA id A339E5425; Fri, 10 Mar 2017 20:14:40 -0500 (EST) X-Sender-Id: kenneth@whitecape.org Received: from localhost.localdomain ([UNAVAILABLE]. [134.134.139.94]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256) by 0.0.0.0:465 (trex/5.7.12); Fri, 10 Mar 2017 20:14:41 -0500 From: Kenneth Graunke To: intel-gfx@lists.freedesktop.org Date: Fri, 10 Mar 2017 17:14:32 -0800 Message-Id: <20170311011432.28962-1-kenneth@whitecape.org> X-Mailer: git-send-email 2.12.0 Cc: mesa-dev@lists.freedesktop.org, Kenneth Graunke Subject: [Intel-gfx] [libdrm PATCH] intel: Make unsynchronized GTT mappings work on systems with snooping. 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 On systems without LLC, drm_intel_gem_bo_map_unsynchronized() has had the surprising behavior of doing a synchronized GTT mapping. This is obviously not what the user of the API wanted. Eric left a comment indicating a valid concern: if the CPU and GPU caches are incoherent, we don't keep track of where the user last mapped the buffer, and what caches might contain relevant data. Modern Atom systems still don't have LLC, but they do offer snooping, which effectively makes the caches coherent. The kernel appears to set up the PTE/PPAT to enable snooping for everything where the cache level is not I915_CACHE_NONE. As far as I know, only scanout buffers are marked as uncached. Any buffers used by scanout should be flagged as non-reusable with drm_intel_bo_disable_reuse(), prime export, or flink. So, we can assume that any reusable buffer should be snooped. This patch enables unsynchronized mappings for reusable buffers on all Gen6+ hardware (which have either LLC or snooping). On Broxton, this improves the performance of Unigine Valley 1.0 on Low settings at 1280x720 by about 45%, and Unigine Heaven 4.0 (same settings) by about 53%. Signed-off-by: Kenneth Graunke Cc: Chris Wilson Cc: mesa-dev@lists.freedesktop.org --- intel/intel_bufmgr_gem.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) It looks like Mesa and Beignet are the only callers of this function (SNA and Anvil don't use libdrm, UXA and vaapi don't use this function.) This passed our full barrage of Piglit/dEQP/GLCTS/GLESCTS testing. gnome-shell still works, as does Unigine, and GLBenchmark. I haven't tested any OpenCL workloads. diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c index e260f2dc..f53f1fcc 100644 --- a/intel/intel_bufmgr_gem.c +++ b/intel/intel_bufmgr_gem.c @@ -1630,9 +1630,7 @@ int drm_intel_gem_bo_map_unsynchronized(drm_intel_bo *bo) { drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bo->bufmgr; -#ifdef HAVE_VALGRIND drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo; -#endif int ret; /* If the CPU cache isn't coherent with the GTT, then use a @@ -1641,8 +1639,12 @@ drm_intel_gem_bo_map_unsynchronized(drm_intel_bo *bo) * terms of drm_intel_bo_map vs drm_intel_gem_bo_map_gtt, so * we would potentially corrupt the buffer even when the user * does reasonable things. + * + * The caches are coherent on LLC platforms or snooping is enabled + * for the BO. The kernel enables snooping for non-scanout (reusable) + * buffers on modern non-LLC systems. */ - if (!bufmgr_gem->has_llc) + if (bufmgr_gem->gen < 6 || !bo_gem->reusable) return drm_intel_gem_bo_map_gtt(bo); pthread_mutex_lock(&bufmgr_gem->lock);