From patchwork Mon Oct 14 12:50:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 11188711 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4FA931575 for ; Mon, 14 Oct 2019 12:51:29 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 37D4721848 for ; Mon, 14 Oct 2019 12:51:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 37D4721848 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 366CE6E2D7; Mon, 14 Oct 2019 12:51:28 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0625E6E2D1 for ; Mon, 14 Oct 2019 12:51:24 +0000 (UTC) Received: by mail-wm1-x344.google.com with SMTP id y21so16640829wmi.0 for ; Mon, 14 Oct 2019 05:51:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T0xL/iDkEL+mRgHC/hRILKSEGgtjkYP7/04WXy0TU5c=; b=W2TJ4PPpsL7NASsagkdGmBWQuStTZmX8Czrab2i2fNMeUCWTdPI0NHEHQf8Pd40J+b vWNtZCAD/AVP01uX+CRWoNqJktkQArvaxDNLvRzGB3F/bDhJhL9EJ1meklMon+AktNd/ aN4+2mvi+oGVPHjfufjTW7MjvbeEDWy9ZyXWQeMfwBhp6gir5W05biXnoPMqVA3TRjVF ImQODvqIAsawBr7zdy/TK5+fTJdI19UG4Z1ABiimMmhHw8OyYUXBXYR8zT0m5L+9179Q lnue7Rzzz/AZiglWYPMX4wZLccpiZdvAdIlk/JcAR/NskFBMcekDxFKLDHeaoqQc1u4b SnUQ== X-Gm-Message-State: APjAAAVCGnKWpZcLdMdRlmy7R+cRvBXFJFIQ6MqfNXKqXzPnkI4qDZbA +91Z04AjJvh3rjPJLuwX1mw= X-Google-Smtp-Source: APXvYqy4hQZbCr4bXF44azC0xINbKmfHk3TGROlTqQmbYp9gts0pMzgY0rJb683HGAO9RY464ZaW0Q== X-Received: by 2002:a1c:f60d:: with SMTP id w13mr15847792wmc.150.1571057481904; Mon, 14 Oct 2019 05:51:21 -0700 (PDT) Received: from localhost (p2E5BE2CE.dip0.t-ipconnect.de. [46.91.226.206]) by smtp.gmail.com with ESMTPSA id a192sm16440939wma.1.2019.10.14.05.51.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 05:51:20 -0700 (PDT) From: Thierry Reding To: Thierry Reding Subject: [PATCH 14/14] drm/tegra: gem: Use sg_alloc_table_from_pages() Date: Mon, 14 Oct 2019 14:50:49 +0200 Message-Id: <20191014125049.425101-15-thierry.reding@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191014125049.425101-1-thierry.reding@gmail.com> References: <20191014125049.425101-1-thierry.reding@gmail.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T0xL/iDkEL+mRgHC/hRILKSEGgtjkYP7/04WXy0TU5c=; b=oQ2Y1lnIBaHHF4NPbEeUhTFXJAFOjbYO1SZBlITCO+R2+00RLcbPQU3SF9W5KAKV1d JuEtjQFDwm0IhwXV8fZ3d0Pc3sSMUnUrhyziBQKy97RFxdEGMOxENwpW8SqOuGKuDgvE wAUkkwB2HFFyiWo9wc5zLjuJ3ThbdZyaaEKX+JMVtf4tPpElZkZ1zr85Ymmiiz9x9tx0 dTERRZ3SR9eL/8wzZn0yW9npRXzj5FHKao8F3ffjJEbbLs0glkFZHjmYLYE3xNa7L/pd ByUbsXvO6xnUXoBHvna2lv3zdugigTJ1RlC7HM7WXviadepy4eiDCETOEYzZLqId1UVG DujQ== 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: , Cc: linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Thierry Reding Instead of manually creating the SG table for a discontiguous buffer, use the existing sg_alloc_table_from_pages(). Note that this is not safe to be used with the ARM DMA/IOMMU integration code because that will not ensure that the whole buffer is mapped contiguously. Depending on the size of the individual entries the mapping may end up containing holes to ensure alignment. However, we only ever use these buffers with explicit IOMMU API usage and know how to avoid these holes. Signed-off-by: Thierry Reding --- drivers/gpu/drm/tegra/gem.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c index 00701cadaceb..d2f88cc3134f 100644 --- a/drivers/gpu/drm/tegra/gem.c +++ b/drivers/gpu/drm/tegra/gem.c @@ -508,14 +508,9 @@ tegra_gem_prime_map_dma_buf(struct dma_buf_attachment *attach, return NULL; if (bo->pages) { - struct scatterlist *sg; - unsigned int i; - - if (sg_alloc_table(sgt, bo->num_pages, GFP_KERNEL)) + if (sg_alloc_table_from_pages(sgt, bo->pages, bo->num_pages, + 0, gem->size, GFP_KERNEL) < 0) goto free; - - for_each_sg(sgt->sgl, sg, bo->num_pages, i) - sg_set_page(sg, bo->pages[i], PAGE_SIZE, 0); } else { if (dma_get_sgtable(attach->dev, sgt, bo->vaddr, bo->iova, gem->size) < 0)