From patchwork Fri Nov 13 17:12:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zanoni, Paulo R" X-Patchwork-Id: 7613001 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A80759F443 for ; Fri, 13 Nov 2015 17:13:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7F67A2065D for ; Fri, 13 Nov 2015 17:13:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 75E1120653 for ; Fri, 13 Nov 2015 17:13:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 72D776E600; Fri, 13 Nov 2015 09:13:11 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id E02376E62E for ; Fri, 13 Nov 2015 09:13:10 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP; 13 Nov 2015 09:13:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,288,1444719600"; d="scan'208";a="837185198" Received: from jh1011-mobl1.gar.corp.intel.com (HELO panetone.amr.corp.intel.com) ([10.252.192.177]) by fmsmga001.fm.intel.com with ESMTP; 13 Nov 2015 09:13:08 -0800 From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Fri, 13 Nov 2015 15:12:45 -0200 Message-Id: <1447434771-19337-5-git-send-email-paulo.r.zanoni@intel.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1447434771-19337-1-git-send-email-paulo.r.zanoni@intel.com> References: <1447434771-19337-1-git-send-email-paulo.r.zanoni@intel.com> Subject: [Intel-gfx] [PATCH igt 04/10] lib/igt_fb: also pass the stride to igt_create_fb_with_bo_size() 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.5 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 If the caller is going to specify a custom size, it's likely that he will also specify a custom stride. The automatic stride picked by create_bo_for_fb() is too huge for tiled buffers, so if the caller wants smaller buffers, then he'll need a smaller stride too, otherwise the Kernel will reject the addfb IOCTL due to stride * height being bigger than the size. I want to make tests/kms_frontbuffer_tracking use igt_create_fb_with_bo_size() so I can provide smaller buffers that will fit into the CFB. I'm also planning to make all frontbuffers with the same width/height/format have the same stride and size regardless of tiling method so I can exercise specific code paths. Signed-off-by: Paulo Zanoni --- lib/igt_fb.c | 25 ++++++++++++++++--------- lib/igt_fb.h | 3 ++- tests/kms_flip.c | 2 +- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/igt_fb.c b/lib/igt_fb.c index 2818c9f..3ea9915 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -76,9 +76,8 @@ static struct format_desc_struct { /* helpers to create nice-looking framebuffers */ static int create_bo_for_fb(int fd, int width, int height, int bpp, uint64_t tiling, unsigned bo_size, - uint32_t *gem_handle_ret, - unsigned *size_ret, - unsigned *stride_ret) + unsigned bo_stride, uint32_t *gem_handle_ret, + unsigned *size_ret, unsigned *stride_ret) { uint32_t gem_handle; int size, ret = 0; @@ -110,12 +109,16 @@ static int create_bo_for_fb(int fd, int width, int height, int bpp, if (bo_size == 0) bo_size = size; + if (bo_stride == 0) + bo_stride = stride; + gem_handle = gem_create(fd, bo_size); if (tiling == LOCAL_I915_FORMAT_MOD_X_TILED) - ret = __gem_set_tiling(fd, gem_handle, I915_TILING_X, stride); + ret = __gem_set_tiling(fd, gem_handle, I915_TILING_X, + bo_stride); - *stride_ret = stride; + *stride_ret = bo_stride; *size_ret = bo_size; *gem_handle_ret = gem_handle; @@ -401,6 +404,7 @@ void igt_paint_image(cairo_t *cr, const char *filename, * @tiling: tiling layout of the framebuffer (as framebuffer modifier) * @fb: pointer to an #igt_fb structure * @bo_size: size of the backing bo (0 for automatic size) + * @bo_stride: stride of the backing bo (0 for automatic stride) * * This function allocates a gem buffer object suitable to back a framebuffer * with the requested properties and then wraps it up in a drm framebuffer @@ -415,7 +419,8 @@ void igt_paint_image(cairo_t *cr, const char *filename, unsigned int igt_create_fb_with_bo_size(int fd, int width, int height, uint32_t format, uint64_t tiling, - struct igt_fb *fb, unsigned bo_size) + struct igt_fb *fb, unsigned bo_size, + unsigned bo_stride) { uint32_t fb_id; int bpp; @@ -427,7 +432,8 @@ igt_create_fb_with_bo_size(int fd, int width, int height, igt_debug("%s(width=%d, height=%d, format=0x%x [bpp=%d], tiling=0x%"PRIx64", size=%d)\n", __func__, width, height, format, bpp, tiling, bo_size); do_or_die(create_bo_for_fb(fd, width, height, bpp, tiling, bo_size, - &fb->gem_handle, &fb->size, &fb->stride)); + bo_stride, &fb->gem_handle, &fb->size, + &fb->stride)); igt_debug("%s(handle=%d, pitch=%d)\n", __func__, fb->gem_handle, fb->stride); @@ -485,7 +491,8 @@ igt_create_fb_with_bo_size(int fd, int width, int height, unsigned int igt_create_fb(int fd, int width, int height, uint32_t format, uint64_t tiling, struct igt_fb *fb) { - return igt_create_fb_with_bo_size(fd, width, height, format, tiling, fb, 0); + return igt_create_fb_with_bo_size(fd, width, height, format, tiling, fb, + 0, 0); } /** @@ -714,7 +721,7 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb) */ bpp = igt_drm_format_to_bpp(fb->drm_format); ret = create_bo_for_fb(fd, fb->width, fb->height, bpp, - LOCAL_DRM_FORMAT_MOD_NONE, 0, + LOCAL_DRM_FORMAT_MOD_NONE, 0, 0, &blit->linear.handle, &blit->linear.size, &blit->linear.stride); diff --git a/lib/igt_fb.h b/lib/igt_fb.h index a07acd2..37892b5 100644 --- a/lib/igt_fb.h +++ b/lib/igt_fb.h @@ -72,7 +72,8 @@ enum igt_text_align { unsigned int igt_create_fb_with_bo_size(int fd, int width, int height, uint32_t format, uint64_t tiling, - struct igt_fb *fb, unsigned bo_size); + struct igt_fb *fb, unsigned bo_size, + unsigned bo_stride); unsigned int igt_create_fb(int fd, int width, int height, uint32_t format, uint64_t tiling, struct igt_fb *fb); unsigned int igt_create_color_fb(int fd, int width, int height, diff --git a/tests/kms_flip.c b/tests/kms_flip.c index e1b5856..e65fef2 100644 --- a/tests/kms_flip.c +++ b/tests/kms_flip.c @@ -1390,7 +1390,7 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, tiling, &o->fb_info[0]); o->fb_ids[1] = igt_create_fb_with_bo_size(drm_fd, o->fb_width, o->fb_height, igt_bpp_depth_to_drm_format(o->bpp, o->depth), - tiling, &o->fb_info[1], bo_size); + tiling, &o->fb_info[1], bo_size, 0); o->fb_ids[2] = igt_create_fb(drm_fd, o->fb_width, o->fb_height, igt_bpp_depth_to_drm_format(o->bpp, o->depth), LOCAL_I915_FORMAT_MOD_X_TILED, &o->fb_info[2]);