From patchwork Thu Oct 13 09:04:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 9374579 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BC8B160839 for ; Thu, 13 Oct 2016 09:04:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC46829E6B for ; Thu, 13 Oct 2016 09:04:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A119329E7C; Thu, 13 Oct 2016 09:04:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4B93F29E6B for ; Thu, 13 Oct 2016 09:04:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C24806E9CB; Thu, 13 Oct 2016 09:04:24 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-lf0-x243.google.com (mail-lf0-x243.google.com [IPv6:2a00:1450:4010:c07::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id E31D76E3E3 for ; Thu, 13 Oct 2016 09:04:19 +0000 (UTC) Received: by mail-lf0-x243.google.com with SMTP id b75so11439485lfg.3 for ; Thu, 13 Oct 2016 02:04:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ursulin-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=03URtlmLbZ90K+NXC3sS/c5tm6AJhpHZMfdiItZfQnI=; b=ChPtEOV9DHQcclQGSNkXdpT6KzWLZhTMj/Ir0EE5M0TBENWFtCSNy9XstiJLDZOEwY BKU45LhCvQub400/E70GT1SYvDDvcOniSayxGV1AgMX0TWZLi+Sp7XKwZECXsO6P3UEX DYO1XM2/U7w2kk3XBn3u/6y7rX3u+3ENZh/TXUZcDxg6wOs/M7+y5tl/U0pMpBFRhLUd bK8Vulzi8RR5MQoZFqe2UvFamxE+Xto/eK6UNB3FvKVsZFV5d0HNWwH3VTZEoLb3oaJv /7s7TH4Yb4y3sNZmTiWSBPokl4z4qhafYfLuuodvktcV+GPcWzrkPRMljFnMsPG3SF54 XdIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=03URtlmLbZ90K+NXC3sS/c5tm6AJhpHZMfdiItZfQnI=; b=b2tyZYp0fJsJBKHD/Iu6SHSeI7AwoItPhRS36/QzHQL44UJJVap+LyoXXlg36zoq2+ CSTLV2VowcW7S9Iyn0tLl0EUToyu0+HOsEWvPkIHnCURdGS5EuXIXLy7My+LbxwjkDCn iPcBx4n/UvUlXjXNdw5TQb+qdviZ+F3jN9fr20569INquw44tNbPw0QKwQxQ+ac5Sak8 AfyfjX6fC18h0HYswHWwWUE5FUxuCqJSnW6qO969BgbcX4MboWt6qrNz4tB8rKrfJEWx 1F238yO2tCmE7YMmMtnedBPxdslScUKdYxQUy1QvWY47/6YCSJuAFTHhoYybWVWAEw1X lkLA== X-Gm-Message-State: AA6/9RmEp9XIqzAPUbmRu38od5ZCZbmkeP15AT5Lq6vzDvREdT8BVHPJNLEXtnEb7Xw/BQ== X-Received: by 10.194.114.40 with SMTP id jd8mr6417803wjb.191.1476349458121; Thu, 13 Oct 2016 02:04:18 -0700 (PDT) Received: from localhost.localdomain ([2a02:c7d:9b6d:e300:916a:6cab:ac67:71c2]) by smtp.gmail.com with ESMTPSA id y2sm20776894wjx.20.2016.10.13.02.04.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Oct 2016 02:04:17 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Thu, 13 Oct 2016 10:04:01 +0100 Message-Id: <1476349444-7331-5-git-send-email-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1476349444-7331-1-git-send-email-tvrtko.ursulin@linux.intel.com> References: <1476349444-7331-1-git-send-email-tvrtko.ursulin@linux.intel.com> Subject: [Intel-gfx] [RFC 4/7] drm/i915: Use i915_sg_create for rotated pages view 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-Virus-Scanned: ClamAV using ClamSMTP From: Tvrtko Ursulin As for the partial view, just simplifies the loop and enables entry coalescing. Signed-off-by: Tvrtko Ursulin --- drivers/gpu/drm/i915/i915_gem_gtt.c | 42 +++++++++++++------------------------ 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index f0c70e7c8daa..655c31182c68 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c @@ -3464,11 +3464,10 @@ i915_gem_obj_lookup_or_create_vma(struct drm_i915_gem_object *obj, return vma; } -static struct scatterlist * +static void rotate_pages(const dma_addr_t *in, unsigned int offset, - unsigned int width, unsigned int height, - unsigned int stride, - struct sg_table *st, struct scatterlist *sg) + unsigned int width, unsigned int height, unsigned int stride, + struct i915_sg_create_state *state) { unsigned int column, row; unsigned int src_idx; @@ -3476,34 +3475,27 @@ rotate_pages(const dma_addr_t *in, unsigned int offset, for (column = 0; column < width; column++) { src_idx = stride * (height - 1) + column; for (row = 0; row < height; row++) { - st->nents++; /* We don't need the pages, but need to initialize * the entries so the sg list can be happily traversed. * The only thing we need are DMA addresses. */ - sg_set_page(sg, NULL, PAGE_SIZE, 0); - sg_dma_address(sg) = in[offset + src_idx]; - sg_dma_len(sg) = PAGE_SIZE; - sg = sg_next(sg); + i915_sg_add_dma(state, in[offset + src_idx]); src_idx -= stride; } } - - return sg; } static struct sg_table * intel_rotate_fb_obj_pages(const struct intel_rotation_info *rot_info, struct drm_i915_gem_object *obj) { + struct i915_sg_create_state *state; const size_t n_pages = obj->base.size / PAGE_SIZE; unsigned int size = intel_rotation_info_size(rot_info); struct sgt_iter sgt_iter; dma_addr_t dma_addr; unsigned long i; dma_addr_t *page_addr_list; - struct sg_table *st; - struct scatterlist *sg; int ret = -ENOMEM; /* Allocate a temporary list of source pages for random access. */ @@ -3513,14 +3505,12 @@ intel_rotate_fb_obj_pages(const struct intel_rotation_info *rot_info, if (!page_addr_list) return ERR_PTR(ret); - /* Allocate target SG list. */ - st = kmalloc(sizeof(*st), GFP_KERNEL); - if (!st) + /* Begin creation of the target SG list. */ + state = i915_sg_create(size); + if (IS_ERR(state)) { + ret = PTR_ERR(state); goto err_st_alloc; - - ret = sg_alloc_table(st, size, GFP_KERNEL); - if (ret) - goto err_sg_alloc; + } /* Populate source page list from the object. */ i = 0; @@ -3528,13 +3518,11 @@ intel_rotate_fb_obj_pages(const struct intel_rotation_info *rot_info, page_addr_list[i++] = dma_addr; GEM_BUG_ON(i != n_pages); - st->nents = 0; - sg = st->sgl; for (i = 0 ; i < ARRAY_SIZE(rot_info->plane); i++) { - sg = rotate_pages(page_addr_list, rot_info->plane[i].offset, - rot_info->plane[i].width, rot_info->plane[i].height, - rot_info->plane[i].stride, st, sg); + rotate_pages(page_addr_list, rot_info->plane[i].offset, + rot_info->plane[i].width, rot_info->plane[i].height, + rot_info->plane[i].stride, state); } DRM_DEBUG_KMS("Created rotated page mapping for object size %zu (%ux%u tiles, %u pages)\n", @@ -3542,10 +3530,8 @@ intel_rotate_fb_obj_pages(const struct intel_rotation_info *rot_info, drm_free_large(page_addr_list); - return st; + return i915_sg_complete(state); -err_sg_alloc: - kfree(st); err_st_alloc: drm_free_large(page_addr_list);