From patchwork Fri Jun 16 18:10:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9792647 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 4661860326 for ; Fri, 16 Jun 2017 18:13:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40B7D2625B for ; Fri, 16 Jun 2017 18:13:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 357722866B; Fri, 16 Jun 2017 18:13:51 +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=unavailable version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DD3682625B for ; Fri, 16 Jun 2017 18:13:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dLviY-0007gu-Rp; Fri, 16 Jun 2017 18:11:34 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dLviX-0007fh-Ef for xen-devel@lists.xenproject.org; Fri, 16 Jun 2017 18:11:33 +0000 Received: from [193.109.254.147] by server-7.bemta-6.messagelabs.com id B0/D2-03620-45F14495; Fri, 16 Jun 2017 18:11:32 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsXiaHS5VTdE3iX SoHkhq8X3LZOZHBg9Dn+4whLAGMWamZeUX5HAmnF/5lT2gjViFdN3rWRsYPwo1MXIxcEicIJN onvFc1YQR0jgBKPEgSmr2boYOTnYBFQk3jzvYQdJiAgcYpE4+eYoE0iCWUBB4te9TUAdHBzCA nYSPxeZgoRZBFQldm56ygIS5hXQl/jxUhEkLCEgL7Gr7SIriM0pYCDx88g2RhBbCKhkys27jC DjJQRaGCXaLq5gmcDIs4CRYRWjRnFqUVlqka6xoV5SUWZ6RkluYmaOrqGBmV5uanFxYnpqTmJ SsV5yfu4mRqDnGYBgB2PTosBDjJIcTEqivO+fOEcK8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuBd JesSKSRYlJqeWpGWmQMMQZi0BAePkgjvfj6gNG9xQWJucWY6ROoUo6KUOK+DHFBCACSRUZoH1 wYL+0uMslLCvIxAhwjxFKQW5WaWoMq/YhTnYFQS5u2WAZrCk5lXAjf9FdBiJqDFQRccQBaXJC KkpBoYV23au0fgSozqFSnHu1el1iSyfzx2b0FCpcx0obr8AtFX9w7yb9rtk6GjL3Ppm9+jDe3 O1au2FxVcypnG//DfT09X98NhaQ8FHWfWmweYPbGynudyUpCfvbPk/fuHrqfz++b/lZt5QmFb Z0B37t65Tzx9z5pPTVA4qZRp8+a6p8e7/2HTr7xdo8RSnJFoqMVcVJwIAI9RFYR2AgAA X-Env-Sender: BATV+48ca1ab4adaecdf09dc3+5045+infradead.org+hch@bombadil.s rs.infradead.org X-Msg-Ref: server-14.tower-27.messagelabs.com!1497636690!95645779!1 X-Originating-IP: [65.50.211.133] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 34902 invoked from network); 16 Jun 2017 18:11:31 -0000 Received: from bombadil.infradead.org (HELO bombadil.infradead.org) (65.50.211.133) by server-14.tower-27.messagelabs.com with AES256-GCM-SHA384 encrypted SMTP; 16 Jun 2017 18:11:31 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding: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=G6PwcMBv2fhLxqRM08WwX1zyNVvoDV537aNYRx8MfMY=; b=gWf+LHefqlm9BWM2Er7xd3J4r wKoAwyYB5kRSb8YfCHwTFcBQIh9jz6/DbTyGmocyYGAlttzSgcqhdcvHmHssxE9Fl/ycKj4qU0XS+ TXT7Bfvb2yvVq1JZlfDxJRzqYoK1NxITYdXxdrRx7472hWtBdTI18TMhCZ/Z0Hv6XP3Drq45Txyoy BoKJq4XmMOU1U4F2s2BWLX1Uozn8ph31GQ+n4PyfJfADBrToDPq3HzLB5W+HnaWOlxqNFBhUcqpul 903id0O5NGpnoHlsh0O1qABGH/IWUpH4luBn9fPohFUldnaie12GaukFA1TdUgMowzFzJW3o+zFln d9GmgRHVA==; Received: from clnet-p099-196.ikbnet.co.at ([83.175.99.196] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1dLviS-0004Vi-Gm; Fri, 16 Jun 2017 18:11:29 +0000 From: Christoph Hellwig To: x86@kernel.org, linux-arm-kernel@lists.infradead.org, xen-devel@lists.xenproject.org, linux-c6x-dev@linux-c6x.org, linux-hexagon@vger.kernel.org, linux-ia64@vger.kernel.org, linux-mips@linux-mips.org, openrisc@lists.librecores.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-xtensa@linux-xtensa.org, dmaengine@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org, iommu@lists.linux-foundation.org, netdev@vger.kernel.org Date: Fri, 16 Jun 2017 20:10:21 +0200 Message-Id: <20170616181059.19206-7-hch@lst.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170616181059.19206-1-hch@lst.de> References: <20170616181059.19206-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Cc: linux-kernel@vger.kernel.org Subject: [Xen-devel] [PATCH 06/44] iommu/dma: don't rely on DMA_ERROR_CODE X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP DMA_ERROR_CODE is not a public API and will go away soon. dma dma-iommu driver already implements a proper ->mapping_error method, so it's only using the value internally. Add a new local define using the value that arm64 which is the only current user of dma-iommu. Signed-off-by: Christoph Hellwig Reviewed-by: Robin Murphy --- drivers/iommu/dma-iommu.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 62618e77bedc..9403336f1fa6 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -31,6 +31,8 @@ #include #include +#define IOMMU_MAPPING_ERROR 0 + struct iommu_dma_msi_page { struct list_head list; dma_addr_t iova; @@ -500,7 +502,7 @@ void iommu_dma_free(struct device *dev, struct page **pages, size_t size, { __iommu_dma_unmap(iommu_get_domain_for_dev(dev), *handle, size); __iommu_dma_free_pages(pages, PAGE_ALIGN(size) >> PAGE_SHIFT); - *handle = DMA_ERROR_CODE; + *handle = IOMMU_MAPPING_ERROR; } /** @@ -533,7 +535,7 @@ struct page **iommu_dma_alloc(struct device *dev, size_t size, gfp_t gfp, dma_addr_t iova; unsigned int count, min_size, alloc_sizes = domain->pgsize_bitmap; - *handle = DMA_ERROR_CODE; + *handle = IOMMU_MAPPING_ERROR; min_size = alloc_sizes & -alloc_sizes; if (min_size < PAGE_SIZE) { @@ -627,11 +629,11 @@ static dma_addr_t __iommu_dma_map(struct device *dev, phys_addr_t phys, iova = iommu_dma_alloc_iova(domain, size, dma_get_mask(dev), dev); if (!iova) - return DMA_ERROR_CODE; + return IOMMU_MAPPING_ERROR; if (iommu_map(domain, iova, phys - iova_off, size, prot)) { iommu_dma_free_iova(cookie, iova, size); - return DMA_ERROR_CODE; + return IOMMU_MAPPING_ERROR; } return iova + iova_off; } @@ -671,7 +673,7 @@ static int __finalise_sg(struct device *dev, struct scatterlist *sg, int nents, s->offset += s_iova_off; s->length = s_length; - sg_dma_address(s) = DMA_ERROR_CODE; + sg_dma_address(s) = IOMMU_MAPPING_ERROR; sg_dma_len(s) = 0; /* @@ -714,11 +716,11 @@ static void __invalidate_sg(struct scatterlist *sg, int nents) int i; for_each_sg(sg, s, nents, i) { - if (sg_dma_address(s) != DMA_ERROR_CODE) + if (sg_dma_address(s) != IOMMU_MAPPING_ERROR) s->offset += sg_dma_address(s); if (sg_dma_len(s)) s->length = sg_dma_len(s); - sg_dma_address(s) = DMA_ERROR_CODE; + sg_dma_address(s) = IOMMU_MAPPING_ERROR; sg_dma_len(s) = 0; } } @@ -836,7 +838,7 @@ void iommu_dma_unmap_resource(struct device *dev, dma_addr_t handle, int iommu_dma_mapping_error(struct device *dev, dma_addr_t dma_addr) { - return dma_addr == DMA_ERROR_CODE; + return dma_addr == IOMMU_MAPPING_ERROR; } static struct iommu_dma_msi_page *iommu_dma_get_msi_page(struct device *dev,