From patchwork Wed Aug 5 20:10:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiago Vignatti X-Patchwork-Id: 6952701 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 5339BC05AC for ; Wed, 5 Aug 2015 20:10:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 766A3205E3 for ; Wed, 5 Aug 2015 20:10:26 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 1F3DE205C2 for ; Wed, 5 Aug 2015 20:10:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9A22E6E9F0; Wed, 5 Aug 2015 13:10:22 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTP id A3C7C6E1C7; Wed, 5 Aug 2015 13:10:20 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP; 05 Aug 2015 13:10:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,619,1432623600"; d="scan'208";a="777588286" Received: from tvignatt-mobl3.amr.corp.intel.com ([10.254.19.24]) by fmsmga002.fm.intel.com with ESMTP; 05 Aug 2015 13:10:19 -0700 Message-ID: <55C26DA9.9020907@intel.com> Date: Wed, 05 Aug 2015 17:10:17 -0300 From: Tiago Vignatti User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Daniel Vetter References: <1438375344-4954-1-git-send-email-tiago.vignatti@intel.com> <1438375344-4954-2-git-send-email-tiago.vignatti@intel.com> <20150731210234.GA16824@nuc-i3427.alporthouse.com> <55C12EF1.7080701@intel.com> <20150805070810.GL24689@phenom.ffwll.local> In-Reply-To: <20150805070810.GL24689@phenom.ffwll.local> Cc: daniel.vetter@ffwll.ch, intel-gfx@lists.freedesktop.org, daniel.thompson@linaro.org, dri-devel@lists.freedesktop.org Subject: Re: [Intel-gfx] [PATCH 1/2] drm/i915: Use CPU mapping for userspace dma-buf mmap() 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.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 On 08/05/2015 04:08 AM, Daniel Vetter wrote: > On Tue, Aug 04, 2015 at 06:30:25PM -0300, Tiago Vignatti wrote: > Nah they don't have to be equal since the problem isn't that nothing goes > out to memory where the display can see it, but usually only parts of it. > I.e. you need to change your test to > - draw black screen (it starts that way so nothing to do really), grab crtc > - draw white screen and make sure you flush correctly, don't bother with > crc (we can't test for inequality > because collisions are too easy) > - draw black screen again without flushing, grab crc > > Then assert that your two crc will be inequal (which they shouldn't be > because some cachelines will still be stuck). Maybe also add a delay > somewhere so you can see the cacheline dirt pattern, it's very > characteristic. Cool, I've got it now. The test below makes the cachelines dirt, requiring them to get flushed correctly -- I'll work on it now. Should we add that kind of test somewhere in igt BTW? PS: I had an issue with the original kms_pwrite_crc which returns frequent fails. Paulo helped though and showed me that pwrite is currently broken: https://bugs.freedesktop.org/show_bug.cgi?id=86422 Tiago igt_display_t *display = &data->display; @@ -57,6 +71,7 @@ static void test(data_t *data) struct igt_fb *fb = &data->fb[1]; drmModeModeInfo *mode; cairo_t *cr; + char *ptr; uint32_t caching; void *buf; igt_crc_t crc; @@ -67,6 +82,8 @@ static void test(data_t *data) igt_create_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE, fb); + ptr = dmabuf_mmap_framebuffer(data->drm_fd, fb); + cr = igt_get_cairo_ctx(data->drm_fd, fb); igt_paint_test_pattern(cr, fb->width, fb->height); cairo_destroy(cr); @@ -83,11 +100,11 @@ static void test(data_t *data) caching = gem_get_caching(data->drm_fd, fb->gem_handle); igt_assert(caching == I915_CACHING_NONE || caching == I915_CACHING_DISPLAY); - /* use pwrite to make the other fb all white too */ + /* use dmabuf pointer to make the other fb all white too */ buf = malloc(fb->size); igt_assert(buf != NULL); memset(buf, 0xff, fb->size); - gem_write(data->drm_fd, fb->gem_handle, 0, buf, fb->size); + memcpy(ptr, buf, fb->size); free(buf); /* and flip to it */ diff --git a/tests/kms_pwrite_crc.c b/tests/kms_pwrite_crc.c index 05b9e38..419b46d 100644 --- a/tests/kms_pwrite_crc.c +++ b/tests/kms_pwrite_crc.c @@ -50,6 +50,20 @@ typedef struct { uint32_t devid; } data_t; +static char *dmabuf_mmap_framebuffer(int drm_fd, struct igt_fb *fb) +{ + int dma_buf_fd; + char *ptr = NULL; + + dma_buf_fd = prime_handle_to_fd(drm_fd, fb->gem_handle); + igt_assert(errno == 0); + + ptr = mmap(NULL, fb->size, PROT_READ | PROT_WRITE, MAP_SHARED, dma_buf_fd, 0); + igt_assert(ptr != MAP_FAILED); + + return ptr; +} + static void test(data_t *data) {