From patchwork Thu Sep 17 14:19:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 7207861 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AFE39BF036 for ; Thu, 17 Sep 2015 14:19:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C19B3207CB for ; Thu, 17 Sep 2015 14:19:09 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id ADAD0207BB for ; Thu, 17 Sep 2015 14:19:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 63F366EC6D; Thu, 17 Sep 2015 07:19:07 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id B69896EC6D; Thu, 17 Sep 2015 07:19:05 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 17 Sep 2015 07:19:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,547,1437462000"; d="scan'208";a="563583929" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by FMSMGA003.fm.intel.com with SMTP; 17 Sep 2015 07:19:03 -0700 Received: by stinkbox (sSMTP sendmail emulation); Thu, 17 Sep 2015 17:19:02 +0300 From: ville.syrjala@linux.intel.com To: intel-gfx@lists.freedesktop.org Date: Thu, 17 Sep 2015 17:19:02 +0300 Message-Id: <1442499542-16633-1-git-send-email-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.4.6 MIME-Version: 1.0 Cc: Ilia Mirkin , dri-devel@lists.freedesktop.org Subject: [Intel-gfx] [PATCH libdrm] intel: Use CPU mmap for unsynchronized map with linear buffers 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ville Syrjälä On LLC platforms there's no need to use GTT mmap for unsynchronized maps if the object isn't tiled. So switch to using CPU mmap for linar objects. This avoids having to use the GTT for GL buffer objects entirely, and thus we can ignore the GTT mappable size limitation. For tiled objects we still want the hardware to do the (de)tiling so keep using GTT for such objects. The display engine is not coherent even on LLC platforms, so this won't work too well if we mix scanout and unsynchronized maps of linear bos. Actually, that would only be a problem for an already uncached object, otherwise it will get clflushed anyway when being made UC/WC prior to scanout. The alreday UC object case could be handled by either clflushing straight from userspace, or we could add a new ioctl to clflush or mark the object as cache_dirty so that it will get clflushed in the future just prior to scanout. I started to think that a small nop pwrite would have the desired effect, but in fact it would only flush the cachelines it touches so wouldn't actually work I doubt we want to pwrite the entire object just to get it clflushed. This fixes Ilias's arb_texture_buffer_object-max-size piglit test on LLC platforms. Cc: Ilia Mirkin Signed-off-by: Ville Syrjälä --- intel/intel_bufmgr_gem.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c index 63122d0..5e8335a 100644 --- a/intel/intel_bufmgr_gem.c +++ b/intel/intel_bufmgr_gem.c @@ -1337,11 +1337,10 @@ static void drm_intel_gem_bo_unreference(drm_intel_bo *bo) } } -static int drm_intel_gem_bo_map(drm_intel_bo *bo, int write_enable) +static int map_cpu(drm_intel_bo *bo) { drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bo->bufmgr; drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo; - struct drm_i915_gem_set_domain set_domain; int ret; if (bo_gem->is_userptr) { @@ -1350,8 +1349,6 @@ static int drm_intel_gem_bo_map(drm_intel_bo *bo, int write_enable) return 0; } - pthread_mutex_lock(&bufmgr_gem->lock); - if (bo_gem->map_count++ == 0) drm_intel_gem_bo_open_vma(bufmgr_gem, bo_gem); @@ -1384,6 +1381,24 @@ static int drm_intel_gem_bo_map(drm_intel_bo *bo, int write_enable) bo_gem->mem_virtual); bo->virtual = bo_gem->mem_virtual; + return 0; +} + +static int drm_intel_gem_bo_map(drm_intel_bo *bo, int write_enable) +{ + drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bo->bufmgr; + drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo; + struct drm_i915_gem_set_domain set_domain; + int ret; + + pthread_mutex_lock(&bufmgr_gem->lock); + + ret = map_cpu(bo); + if (ret || bo_gem->is_userptr) { + pthread_mutex_unlock(&bufmgr_gem->lock); + return ret; + } + memclear(set_domain); set_domain.handle = bo_gem->gem_handle; set_domain.read_domains = I915_GEM_DOMAIN_CPU; @@ -1536,9 +1551,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 @@ -1553,7 +1566,10 @@ drm_intel_gem_bo_map_unsynchronized(drm_intel_bo *bo) pthread_mutex_lock(&bufmgr_gem->lock); - ret = map_gtt(bo); + if (bo_gem->tiling_mode == I915_TILING_NONE) + ret = map_cpu(bo); + else + ret = map_gtt(bo); if (ret == 0) { drm_intel_gem_bo_mark_mmaps_incoherent(bo); VG(VALGRIND_MAKE_MEM_DEFINED(bo_gem->gtt_virtual, bo->size));