From patchwork Tue Mar 8 14:51:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 8535011 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 9477AC0553 for ; Tue, 8 Mar 2016 14:52:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AE764201C8 for ; Tue, 8 Mar 2016 14:52:49 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 6B185201FA for ; Tue, 8 Mar 2016 14:52:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1997C6E6EE; Tue, 8 Mar 2016 14:52:46 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 00A9B6E6EE for ; Tue, 8 Mar 2016 14:52:31 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id l68so4535557wml.3 for ; Tue, 08 Mar 2016 06:52:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Tex93zM/7h70f87msWMKV2WZCEfOlGz+ZISu/0cJuwk=; b=A/Mh8HIZX+OTT/B9vIN0GhCPpqlsap3W+xNHzNLyDi/WEwnQ1LGfvJbKa3XE2eJVkz V0LSOHxmCCSSkWnKPFxlDSa61WQwQK/dZdpk3RidrLBVG/94FKhevRMzwz+OJEKDVgNN qEfAJ4AP+yEN/y3c+VhpIlueAGwEYbveNbl8Wn4q/68z7pMCMsxGN4eG0+DmXTwKtria A6F1wOgNK9kVByp7LylY3atFIbOXoZxkGjLC9EOw/wcZuavCobwn0pwLQ2bTR1bD5Xkr Cc/PBvRXyNwHACPP5RSa2wSSyF5+tbciYaTFVUiXeyj4i9O6oaaRPx0feb6sWzGDwu99 sF0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Tex93zM/7h70f87msWMKV2WZCEfOlGz+ZISu/0cJuwk=; b=mSTlQIbAqo1U37V7Jol0muonHTaQWNWXjWLPsJlrwRQBkILwYEERDyGB8iYDJcNWpH j4g6CHDYuI5HHrppkLGVvQeN66b16K1tEzk/ahp5dPmvJL3Fe55Dq5/qBVuY7v14Uagq HvkIyowqTxofX3CaDDTLjZnDWN6zviD5CCo1KZQgkVKzgJPqHO5FsnHhsqTDPxZ2SQYn Z10ZpZJoXSQaYdvezhD/d0fQ3N5oLT1fOzFsykVHfHkl6WeI7wp8smZ6M6qL6Jx66YLZ o+Vx7hv8bKD08Rezl1q2SjTiEtysbqyR1io+0kK2+cw8Sgdhx7PhPk8IDUPHkp1QJ+K3 r0nA== X-Gm-Message-State: AD7BkJIh6qVGFmyH+6zc4zM3hGEIBKxmTH/xnwshk/syooNHCfloylDnOG5gXiDz5oK2vQ== X-Received: by 10.194.103.5 with SMTP id fs5mr29447189wjb.42.1457448750258; Tue, 08 Mar 2016 06:52:30 -0800 (PST) Received: from cizrna.lan ([109.72.12.208]) by smtp.gmail.com with ESMTPSA id 3sm3781979wmp.14.2016.03.08.06.52.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Mar 2016 06:52:29 -0800 (PST) From: Tomeu Vizoso To: Intel GFX discussion Date: Tue, 8 Mar 2016 15:51:32 +0100 Message-Id: <1457448699-9778-11-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1457448699-9778-1-git-send-email-tomeu.vizoso@collabora.com> References: <1457448699-9778-1-git-send-email-tomeu.vizoso@collabora.com> Cc: Daniel Stone , Tomeu Vizoso , Micah Fedke , Gustavo Padovan , Emil Velikov Subject: [Intel-gfx] [i-g-t PATCH v2 10/17] lib: Map dumb 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: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 If a buffer object is dumb, call DRM_IOCTL_MODE_MAP_DUMB when mapping it. Also, don't call DRM_IOCTL_I915_GEM_SET_DOMAIN on dumb buffers. Signed-off-by: Tomeu Vizoso --- Changes in v2: - Call dirtyfb after the cairo context associated to a FB backed by a dumb buffer is destroyed. For this, I need to store the fd that was used when the FB was created. - Call kmstest_dumb_map_buffer instead of open coding it. lib/igt_fb.c | 17 +++++++++++++++-- lib/igt_fb.h | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/igt_fb.c b/lib/igt_fb.c index 9d6cff0edd23..361f94627659 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -547,6 +547,7 @@ igt_create_fb_with_bo_size(int fd, int width, int height, fb->tiling = tiling; fb->drm_format = format; fb->fb_id = fb_id; + fb->fd = fd; return fb_id; } @@ -999,11 +1000,21 @@ static void destroy_cairo_surface__gtt(void *arg) munmap(cairo_image_surface_get_data(fb->cairo_surface), fb->size); fb->cairo_surface = NULL; + + if (fb->is_dumb) + igt_dirty_fb(fb->fd, fb); } static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) { - void *ptr = gem_mmap__gtt(fd, fb->gem_handle, fb->size, PROT_READ | PROT_WRITE); + void *ptr; + + if (fb->is_dumb) + ptr = kmstest_dumb_map_buffer(fd, fb->gem_handle, fb->size, + PROT_READ | PROT_WRITE); + else + ptr = gem_mmap__gtt(fd, fb->gem_handle, fb->size, + PROT_READ | PROT_WRITE); fb->cairo_surface = cairo_image_surface_create_for_data(ptr, @@ -1026,7 +1037,9 @@ static cairo_surface_t *get_cairo_surface(int fd, struct igt_fb *fb) create_cairo_surface__gtt(fd, fb); } - gem_set_domain(fd, fb->gem_handle, fb->domain, fb->domain); + if (!fb->is_dumb) + gem_set_domain(fd, fb->gem_handle, I915_GEM_DOMAIN_CPU, + I915_GEM_DOMAIN_CPU); igt_assert(cairo_surface_status(fb->cairo_surface) == CAIRO_STATUS_SUCCESS); return fb->cairo_surface; diff --git a/lib/igt_fb.h b/lib/igt_fb.h index ec88854ddeb7..91e91408b340 100644 --- a/lib/igt_fb.h +++ b/lib/igt_fb.h @@ -46,6 +46,7 @@ typedef struct _cairo cairo_t; /* helpers to create nice-looking framebuffers */ struct igt_fb { uint32_t fb_id; + int fd; uint32_t gem_handle; uint32_t drm_format; int width;