Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2680067yba; Mon, 22 Apr 2019 11:01:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqyiDHrJzF5CkpBRkkWYV6SYLtYHUEnpxW1X786QQ0Q2OUuTm1PEjHbMZZda7c4p2Z1wGIIF X-Received: by 2002:a63:720e:: with SMTP id n14mr19518071pgc.93.1555956107282; Mon, 22 Apr 2019 11:01:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555956107; cv=none; d=google.com; s=arc-20160816; b=AmZupwDiQB1hf6jk3lf1JSBE9S6wOFP29woklqeuEXQdNFYp+sjMfSHyY8dSXNBs5D btA1j0Jh4Z185VKPLIGyUPf7w8mvC8GpJfR0/Kl5ATdPhChHd3awiuIc7GfDsRt6CyO9 vSSKeYobnd2kXbi24b58jtHk6rKEVqS5V9+uWRpl8jY47gOzaBw2PQiEufSVfsKIC6DV 5a85sQMLXRHsWWV3WlrazHhtNxhZKJzKLkY8erTZ6oOoLyft/IPl2e1hmBYKS3sMkEjZ pU1PojAB39Op9tyV28xkrcmjiISwnBGe2GcffmpJEOPvhg2PVIeenLhxifIm1LPn7Syo dB9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7nhTx9drEQcJqOCbw3v9FtAi8Oly72Vd6sSVkvckvZs=; b=i9Gyyjk4eXehgm2Zdrf59Mwe93RZ1ZhGBaP89gbZ9pFY5HPDm8yJPNrHDWDluEbJyF qqtxNdHwhxhbyU3dnV0VCe6TysNsIZ59J9gGlcyPDvvbKhApDyoyH9e6miY3Ls/JrxCQ Hqrom075Kh7BbNi6CF6t6+3pqRMzhh06FVUiNRdqRkGMolmsbklRH9FDyB/ncZ6KKmnt RBiNFn8tHjNMV14XDEhrClAHvFp44n9E600TSNmnzONq854irNK7qgRdQQIYK7pcfW2k yNuw9Hfn0IkFQoUBtzFflyQ/3uBwerBDmIFKSRUcit8fZi7Mj7xQGZ6ZEccZGaYkXAUz ayQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=a3NrMkiR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d6si14176431pfr.262.2019.04.22.11.01.31; Mon, 22 Apr 2019 11:01:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=a3NrMkiR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728458AbfDVSAa (ORCPT + 99 others); Mon, 22 Apr 2019 14:00:30 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:35934 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726132AbfDVSA2 (ORCPT ); Mon, 22 Apr 2019 14:00:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=7nhTx9drEQcJqOCbw3v9FtAi8Oly72Vd6sSVkvckvZs=; b=a3NrMkiR34EYEtCSDKzgutD7r8 gxMqXxOs5La0k2J8xmPv/VK0kG4GCEJCE+DWOfe0La+T1mZDePZxU2i8oGPvKLp5JRpa8IvcjvMpG B9TstWrkJ6weYcQDJQvOcNJVaaSMA0567BM2z0uyNWoor8/VKmbgoeTztl8/T98f1idgWNbc5Vav2 UawfHH32M7xePjZcXf9og13uuDj0mg5ZeThAcBbs2UxT+bEqtYvdyG95V9pbQCZdC/GE0DrFnvubp xcP1BOHjKL9Z8E02fWoD3BNjD7gfqnLXhIpMPWhu9jy5KVeyg+mRBVmtXEPES/PVKCdbukHYmsH+d aAiXxdzQ==; Received: from 213-225-37-80.nat.highway.a1.net ([213.225.37.80] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hIdEt-0001dp-5L; Mon, 22 Apr 2019 18:00:23 +0000 From: Christoph Hellwig To: Robin Murphy Cc: Joerg Roedel , Catalin Marinas , Will Deacon , Tom Lendacky , iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/26] iommu/dma: Use for_each_sg in iommu_dma_alloc Date: Mon, 22 Apr 2019 19:59:22 +0200 Message-Id: <20190422175942.18788-7-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190422175942.18788-1-hch@lst.de> References: <20190422175942.18788-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org arch_dma_prep_coherent can handle physically contiguous ranges larger than PAGE_SIZE just fine, which means we don't need a page-based iterator. Signed-off-by: Christoph Hellwig Reviewed-by: Robin Murphy --- drivers/iommu/dma-iommu.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 77d704c8f565..f915cb7c46e6 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -577,15 +577,11 @@ struct page **iommu_dma_alloc(struct device *dev, size_t size, gfp_t gfp, goto out_free_iova; if (!(prot & IOMMU_CACHE)) { - struct sg_mapping_iter miter; - /* - * The CPU-centric flushing implied by SG_MITER_TO_SG isn't - * sufficient here, so skip it by using the "wrong" direction. - */ - sg_miter_start(&miter, sgt.sgl, sgt.orig_nents, SG_MITER_FROM_SG); - while (sg_miter_next(&miter)) - arch_dma_prep_coherent(miter.page, PAGE_SIZE); - sg_miter_stop(&miter); + struct scatterlist *sg; + int i; + + for_each_sg(sgt.sgl, sg, sgt.orig_nents, i) + arch_dma_prep_coherent(sg_page(sg), sg->length); } if (iommu_map_sg(domain, iova, sgt.sgl, sgt.orig_nents, prot) -- 2.20.1