From patchwork Thu Aug 17 12:56:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 9906255 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 1C3906038C for ; Thu, 17 Aug 2017 12:58:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 021FE28A93 for ; Thu, 17 Aug 2017 12:58:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EAF5A28AC9; Thu, 17 Aug 2017 12:58:11 +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=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4A86B28AA1 for ; Thu, 17 Aug 2017 12:58:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=HojwHRBel+/iLXDGt9CRNHQyYgdaz02uLjXUK9zqUtU=; b=MUdhakutcl/TwVoCgDDZUph34G lVQZSypFiFIDxOixmnx9N2GXnrThaMePrv0ozkPXjm144dSS+xCITfNlZsic2iVwbwuUT2lnXU9fv Dp+G5gcoiEPkUpHrO5yxopkRpLFaWLuIZ0YB0EVOxPs8reVz/14oIIilWYRNqeFIL/nCloKBWOB4F iJr/YKNECDzCPbkQj/rzqFTiUuA3GyurU9h7GI4B4bC2cHwt/QmBQ1dtFlYnNEgn9yU/Of+PKzS/A /qIkPgwEomd0isNEOjNvixoVdWwpbh8f7a0P1GeJ/VAqha/nHxNlzq+tbOoxiVzh/EMNWVGE+2puU C48M3lKg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1diKMd-0008Oa-Sj; Thu, 17 Aug 2017 12:57:31 +0000 Received: from 8bytes.org ([2a01:238:4383:600:38bc:a715:4b6d:a889] helo=theia.8bytes.org) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1diKMW-0008M6-Sq for linux-arm-kernel@lists.infradead.org; Thu, 17 Aug 2017 12:57:30 +0000 Received: by theia.8bytes.org (Postfix, from userid 1000) id 184B5241; Thu, 17 Aug 2017 14:56:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1502974615; bh=v6E7dkqQW+JjJ5eAn5uUOPb6+sVuDfYZku2kzYdcCFo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OnsismiF+2aiPBOxjA9j2nh29VvkJPfaQq6QlOVDhFzgUO3H+CJWPlc64QL+QjZi/ w1SWhrVq5FMDIN5Hs6Eg8L5+bXCRE4uxDVMEcFkznIrc1vHVb0wXQki+Kf+24NSV0/ OFKi0g/tz2oPFW6pWWdbY4Pwyu/lFvuZp01IPz+rAe0dBluoy34Fxo678RzWPRYHSc vNtZYrrjI8HFO3UziH6kCmNrafUBLzrqqXv9WQ8IS5MKFuoEqw8RpIkt/zWSeUxBX2 ki7L7t9K6S50utVAEwzlPg+L2+r/pSG1+rQyHzoh89zOtcqQ5sHOrDHAzGh1p+3LZF HWYXt800pzDpQ== From: Joerg Roedel To: iommu@lists.linux-foundation.org Subject: [PATCH 05/13] arm: dma-mapping: Use sychronized interface of the IOMMU-API Date: Thu, 17 Aug 2017 14:56:28 +0200 Message-Id: <1502974596-23835-6-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502974596-23835-1-git-send-email-joro@8bytes.org> References: <1502974596-23835-1-git-send-email-joro@8bytes.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170817_055728_418401_E4B5479C X-CRM114-Status: GOOD ( 11.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Pinchart , linux-kernel@vger.kernel.org, Russell King , Joerg Roedel , Suravee Suthikulpanit , Sricharan R , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Joerg Roedel The map and unmap functions of the IOMMU-API changed their semantics: They do no longer guarantee that the hardware TLBs are synchronized with the page-table updates they made. To make conversion easier, new synchronized functions have been introduced which give these guarantees again until the code is converted to use the new TLB-flush interface of the IOMMU-API, which allows certain optimizations. But for now, just convert this code to use the synchronized functions so that it will behave as before. Cc: Russell King Cc: Laurent Pinchart Cc: Sricharan R Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Joerg Roedel --- arch/arm/mm/dma-mapping.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index fcf1473..fae2398 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1444,7 +1444,7 @@ __iommu_create_mapping(struct device *dev, struct page **pages, size_t size, break; len = (j - i) << PAGE_SHIFT; - ret = iommu_map(mapping->domain, iova, phys, len, + ret = iommu_map_sync(mapping->domain, iova, phys, len, __dma_info_to_prot(DMA_BIDIRECTIONAL, attrs)); if (ret < 0) goto fail; @@ -1453,7 +1453,7 @@ __iommu_create_mapping(struct device *dev, struct page **pages, size_t size, } return dma_addr; fail: - iommu_unmap(mapping->domain, dma_addr, iova-dma_addr); + iommu_unmap_sync(mapping->domain, dma_addr, iova-dma_addr); __free_iova(mapping, dma_addr, size); return ARM_MAPPING_ERROR; } @@ -1469,7 +1469,7 @@ static int __iommu_remove_mapping(struct device *dev, dma_addr_t iova, size_t si size = PAGE_ALIGN((iova & ~PAGE_MASK) + size); iova &= PAGE_MASK; - iommu_unmap(mapping->domain, iova, size); + iommu_unmap_sync(mapping->domain, iova, size); __free_iova(mapping, iova, size); return 0; } @@ -1730,7 +1730,7 @@ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg, prot = __dma_info_to_prot(dir, attrs); - ret = iommu_map(mapping->domain, iova, phys, len, prot); + ret = iommu_map_sync(mapping->domain, iova, phys, len, prot); if (ret < 0) goto fail; count += len >> PAGE_SHIFT; @@ -1740,7 +1740,7 @@ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg, return 0; fail: - iommu_unmap(mapping->domain, iova_base, count * PAGE_SIZE); + iommu_unmap_sync(mapping->domain, iova_base, count * PAGE_SIZE); __free_iova(mapping, iova_base, size); return ret; } @@ -1938,7 +1938,8 @@ static dma_addr_t arm_coherent_iommu_map_page(struct device *dev, struct page *p prot = __dma_info_to_prot(dir, attrs); - ret = iommu_map(mapping->domain, dma_addr, page_to_phys(page), len, prot); + ret = iommu_map_sync(mapping->domain, dma_addr, page_to_phys(page), + len, prot); if (ret < 0) goto fail; @@ -1988,7 +1989,7 @@ static void arm_coherent_iommu_unmap_page(struct device *dev, dma_addr_t handle, if (!iova) return; - iommu_unmap(mapping->domain, iova, len); + iommu_unmap_sync(mapping->domain, iova, len); __free_iova(mapping, iova, len); } @@ -2016,7 +2017,7 @@ static void arm_iommu_unmap_page(struct device *dev, dma_addr_t handle, if ((attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0) __dma_page_dev_to_cpu(page, offset, size, dir); - iommu_unmap(mapping->domain, iova, len); + iommu_unmap_sync(mapping->domain, iova, len); __free_iova(mapping, iova, len); } @@ -2044,7 +2045,7 @@ static dma_addr_t arm_iommu_map_resource(struct device *dev, prot = __dma_info_to_prot(dir, attrs) | IOMMU_MMIO; - ret = iommu_map(mapping->domain, dma_addr, addr, len, prot); + ret = iommu_map_sync(mapping->domain, dma_addr, addr, len, prot); if (ret < 0) goto fail; @@ -2073,7 +2074,7 @@ static void arm_iommu_unmap_resource(struct device *dev, dma_addr_t dma_handle, if (!iova) return; - iommu_unmap(mapping->domain, iova, len); + iommu_unmap_sync(mapping->domain, iova, len); __free_iova(mapping, iova, len); }