From patchwork Thu Mar 24 19:16:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zanoni, Paulo R" X-Patchwork-Id: 8664031 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 3749AC0553 for ; Thu, 24 Mar 2016 19:16:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 58883203A1 for ; Thu, 24 Mar 2016 19:16:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7840020390 for ; Thu, 24 Mar 2016 19:16:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5972B6E9EA; Thu, 24 Mar 2016 19:16:22 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTP id 37AE46E9EA for ; Thu, 24 Mar 2016 19:16:19 +0000 (UTC) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP; 24 Mar 2016 12:16:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,386,1455004800"; d="scan'208";a="675145451" Received: from mabock-mobl2.amr.corp.intel.com (HELO panetone.amr.corp.intel.com) ([10.254.178.24]) by FMSMGA003.fm.intel.com with ESMTP; 24 Mar 2016 12:16:18 -0700 From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Thu, 24 Mar 2016 16:16:09 -0300 Message-Id: <1458846972-20338-3-git-send-email-paulo.r.zanoni@intel.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1458846972-20338-1-git-send-email-paulo.r.zanoni@intel.com> References: <1458846972-20338-1-git-send-email-paulo.r.zanoni@intel.com> Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH xf86-video-intel] sna: Opt-out of the Kernel mmap workaround 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-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 ... by issuing dirtyfb calls upon framebuffer creation. Since the non-working SNA versions just never ever issued dirtyfb or sw_finish calls, the Kernel workaround disables itself in case it sees one of those calls. The problem is that we've fixed the bug by forcing TearFree, so we're still not sending dirtyfb or sw_finish calls, so the Kernel keeps the workaround enabled since it doesn't know we're properly behaving. So issue one dirtyfb call each time we create a framebuffer, making sure the Kernel sets the FB_MMAP_WA_DISABLE flag. Cc: Chris Wilson Signed-off-by: Paulo Zanoni --- src/sna/kgem.c | 14 ++++++++++++++ src/sna/kgem.h | 1 + src/sna/sna_display.c | 1 + src/sna/sna_video_sprite.c | 2 ++ 4 files changed, 18 insertions(+) diff --git a/src/sna/kgem.c b/src/sna/kgem.c index 06c1684..a5969ae 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -5257,6 +5257,18 @@ __kgem_bo_create_as_display(struct kgem *kgem, int size, int tiling, int pitch) return bo; } +void kgem_mmap_wa_opt_out(struct kgem *kgem, uint32_t fb_id) +{ + struct drm_mode_fb_dirty_cmd cmd; + + if (kgem->gen != 0110 || !kgem->has_dirtyfb) + return; + + memset(&cmd, 0, sizeof(cmd)); + cmd.fb_id = fb_id; + (void)drmIoctl(kgem->fd, DRM_IOCTL_MODE_DIRTYFB, &cmd); +} + static void __kgem_bo_make_scanout(struct kgem *kgem, struct kgem_bo *bo, int width, int height) @@ -5306,6 +5318,7 @@ static void __kgem_bo_make_scanout(struct kgem *kgem, DBG(("%s: attached fb=%d to handle=%d\n", __FUNCTION__, arg.fb_id, arg.handle)); bo->delta = arg.fb_id; + kgem_mmap_wa_opt_out(kgem, bo->delta); } } @@ -5479,6 +5492,7 @@ struct kgem_bo *kgem_create_2d(struct kgem *kgem, bo->delta = arg.fb_id; bo->unique_id = kgem_get_unique_id(kgem); + kgem_mmap_wa_opt_out(kgem, bo->delta); DBG((" 2:from scanout: pitch=%d, tiling=%d, handle=%d, id=%d\n", bo->pitch, bo->tiling, bo->handle, bo->unique_id)); diff --git a/src/sna/kgem.h b/src/sna/kgem.h index 3630b5c..02521ae 100644 --- a/src/sna/kgem.h +++ b/src/sna/kgem.h @@ -326,6 +326,7 @@ bool kgem_bo_convert_to_gpu(struct kgem *kgem, struct kgem_bo *bo, unsigned flags); +void kgem_mmap_wa_opt_out(struct kgem *kgem, uint32_t fb_id); bool kgem_bo_is_fenced(struct kgem *kgem, struct kgem_bo *bo); uint32_t kgem_bo_get_binding(struct kgem_bo *bo, uint32_t format); void kgem_bo_set_binding(struct kgem_bo *bo, uint32_t format, uint16_t offset); diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index 7d2478c..68eea42 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -636,6 +636,7 @@ fail: } assert(arg.fb_id != 0); bo->delta = arg.fb_id; + kgem_mmap_wa_opt_out(&sna->kgem, bo->delta); DBG(("%s: attached fb=%d to handle=%d\n", __FUNCTION__, bo->delta, arg.handle)); diff --git a/src/sna/sna_video_sprite.c b/src/sna/sna_video_sprite.c index ae08ef7..d95abaa 100644 --- a/src/sna/sna_video_sprite.c +++ b/src/sna/sna_video_sprite.c @@ -325,6 +325,8 @@ sna_video_sprite_show(struct sna *sna, frame->bo->scanout = true; /* Don't allow the scanout to be cached if not suitable for front */ frame->bo->purged = purged; + + kgem_mmap_wa_opt_out(&sna->kgem, frame->bo->delta); } assert(frame->bo->scanout);