From patchwork Tue Feb 27 11:49:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 10244965 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 8CF6560211 for ; Tue, 27 Feb 2018 11:50:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FEC12886F for ; Tue, 27 Feb 2018 11:50:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D38728912; Tue, 27 Feb 2018 11:50:19 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 A6E1C28847 for ; Tue, 27 Feb 2018 11:50:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 46F896E644; Tue, 27 Feb 2018 11:50:08 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x242.google.com (mail-wr0-x242.google.com [IPv6:2a00:1450:400c:c0c::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0C1796E638; Tue, 27 Feb 2018 11:50:03 +0000 (UTC) Received: by mail-wr0-x242.google.com with SMTP id v111so12319428wrb.3; Tue, 27 Feb 2018 03:50:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=5wScEhW1QmpRY6mS1pb0PcZIBxg/9CGwI255TlRVidM=; b=nmkPM9CawJ2dmJTfY1Y/NNRWL5FiOdxqSU90lGCTQSjZKdfbbH2+TTduv+sPTAKBqr z0fJbOlTzi4qpsjMlO+GLxXF+EAti1eyseTg3xh50pIdkh23AL4/RP97cQzu3cCdoMP/ Cw/KRXYgv/BtCQCZm3QjSfZxaJAcUVZmtvFUnTH2CQqjzlNnrgzt/H2sVyjhXl6TOokB xkJx4be44vvIva4ii3C2/z6CU39L/Eggsb0QoICwvlPwZ6cCJhi7ysX0hpEBq4xmhL/5 reWUhzOjXLV8klg9QxHGkQ1o+nnE/VjNgM+eAW9a5x4ZZfB41y3prGvMewIZeFK+xYtk jtig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5wScEhW1QmpRY6mS1pb0PcZIBxg/9CGwI255TlRVidM=; b=fcNwo20Nv/VNnKpUf7Ck65hoT3INGjoWg3IaaKKsm//F5scTB0eq9f7/W9SG+g9Fup R9HGJPm/c1b3cgh2W5TVapbAK2Vo1dUBJlCfXHytU2K/UwDUIF8bVS8BbKuAjTGT6+VZ RqmXNs8+s6HOaP3EhhecdTloK67qFESqQqAqyfcrGdFYfoHoHDxbjb0bx26GOYyt4nXX 1UOjP1V768oVNtUAYmjvh//decS86VSu0qzmGyFRL2OhNxmC9XeQuWu0F4r4nervWV69 TSnQ+W+WyUkMvTHjBlUZ1xLQ8DrU1LmSq03BHSRUXE1LUNzR3Kd/oHRkjn417/qqyz+4 Kq+A== X-Gm-Message-State: APf1xPAODZeJh6fIw8NE34gkf94XwniW/hDZvwPKjVDvhZv4mB3yIpIa U7mYngRBQ/y0PSArWanvj2CzIw== X-Google-Smtp-Source: AH8x224xU6GxdvmLiLpdaeDcQjB5c6xedZv9vhtcvHsSnvQM/7AOUWr/vlJvq6mWBv9ZlszUMwOAug== X-Received: by 10.223.152.73 with SMTP id v67mr12148838wrb.19.1519732202357; Tue, 27 Feb 2018 03:50:02 -0800 (PST) Received: from baker.fritz.box ([2a02:908:1251:8fc0:652a:9b33:8ae4:9f2c]) by smtp.gmail.com with ESMTPSA id k2sm8618568wmf.10.2018.02.27.03.50.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 03:50:01 -0800 (PST) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH 2/5] drm/prime: make the pages array optional for drm_prime_sg_to_page_addr_arrays Date: Tue, 27 Feb 2018 12:49:57 +0100 Message-Id: <20180227115000.4105-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180227115000.4105-1-christian.koenig@amd.com> References: <20180227115000.4105-1-christian.koenig@amd.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Most of the time we only need the dma addresses. Signed-off-by: Christian König --- drivers/gpu/drm/drm_prime.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index c38dacda6119..7856a9b3f8a8 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -922,40 +922,40 @@ EXPORT_SYMBOL(drm_prime_pages_to_sg); /** * drm_prime_sg_to_page_addr_arrays - convert an sg table into a page array * @sgt: scatter-gather table to convert - * @pages: array of page pointers to store the page array in + * @pages: optional array of page pointers to store the page array in * @addrs: optional array to store the dma bus address of each page - * @max_pages: size of both the passed-in arrays + * @max_entries: size of both the passed-in arrays * * Exports an sg table into an array of pages and addresses. This is currently * required by the TTM driver in order to do correct fault handling. */ int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages, - dma_addr_t *addrs, int max_pages) + dma_addr_t *addrs, int max_entries) { unsigned count; struct scatterlist *sg; struct page *page; - u32 len; - int pg_index; + u32 len, index; dma_addr_t addr; - pg_index = 0; + index = 0; for_each_sg(sgt->sgl, sg, sgt->nents, count) { len = sg->length; page = sg_page(sg); addr = sg_dma_address(sg); while (len > 0) { - if (WARN_ON(pg_index >= max_pages)) + if (WARN_ON(index >= max_entries)) return -1; - pages[pg_index] = page; + if (pages) + pages[index] = page; if (addrs) - addrs[pg_index] = addr; + addrs[index] = addr; page++; addr += PAGE_SIZE; len -= PAGE_SIZE; - pg_index++; + index++; } } return 0;