From patchwork Thu Jun 8 13:25:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9774777 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 2C93460393 for ; Thu, 8 Jun 2017 13:28:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E4D528451 for ; Thu, 8 Jun 2017 13:28:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 12FF92850E; Thu, 8 Jun 2017 13:28:50 +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=ham 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 ACA0728520 for ; Thu, 8 Jun 2017 13:28:49 +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 1dIxSY-0003Ay-KH; Thu, 08 Jun 2017 13:26:46 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dIxSW-00039Y-QB for xen-devel@lists.xenproject.org; Thu, 08 Jun 2017 13:26:44 +0000 Received: from [85.158.143.35] by server-4.bemta-6.messagelabs.com id CC/5F-02956-49059395; Thu, 08 Jun 2017 13:26:44 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsXiaHS5VXdygGW kwdv34hbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bWy0oFu8UqGruWsDYwNgh3MXJxsAicYJNo fLOeBcQREjjBKHF26Wy2LkZODjYBFYk3z3vYQRIiAodYJE6+OcoEkmAWUJD4dW8TaxcjB4ewg J3Ez0WmIGEWAVWJI02fGEFsXgF9iROf3oHNkRCQl9jVdpEVxOYUMJBoOb0LbIwQUM2hBdOYQe ZLCLQwSrRdXMEygZFnASPDKkb14tSistQiXVO9pKLM9IyS3MTMHF1DAzO93NTi4sT01JzEpGK 95PzcTYxAvzMAwQ7G6Zf9DzFKcjApifIqClhGCvEl5adUZiQWZ8QXleakFh9ilOHgUJLgTfAH ygkWpaanVqRl5gADECYtwcGjJML73wcozVtckJhbnJkOkTrFqCglzlsA0icAksgozYNrgwX9J UZZKWFeRqBDhHgKUotyM0tQ5V8xinMwKgnzuvkCTeHJzCuBm/4KaDET0OIl7yxAFpckIqSkGh jrxTg3v3TfEDdJv/PkVqUgB1atUK2dCglT91yxlmuLeLtKT726WlLzQ+SOPgOP35tlufyD+/Y +/BcTzXP6b5lcq+tRFd5jJ9yUGaIYZzJf6vI3Nz2XcCql5OXXxz7z5qtHHLzENWm2nt8jr1LB 5JKJr6KNAx/4h52q952kaLs2yVFUx7amTImlOCPRUIu5qDgRACXrUwR1AgAA X-Env-Sender: BATV+eb06f239ea6f59aeb59b+5037+infradead.org+hch@bombadil.s rs.infradead.org X-Msg-Ref: server-6.tower-21.messagelabs.com!1496928401!49883979!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 25771 invoked from network); 8 Jun 2017 13:26:43 -0000 Received: from bombadil.infradead.org (HELO bombadil.infradead.org) (65.50.211.133) by server-6.tower-21.messagelabs.com with AES256-GCM-SHA384 encrypted SMTP; 8 Jun 2017 13:26:43 -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=dS/Sr4yNzJTgOXlGLtQH5Z/3++0lO3XctvhSysctBVY=; b=J7iaT5DsQQGQH6fXQTn0oiwAq t7d34/pUtKmTj4DTUOAVEWvPTnHn/H9qpyAu8jyZzIG8ZgsNysbIJoo0XyPU9b7QVRzf0s3I1oWvW wskQlQhlpbAuRJDUdKhJr5XIpmldANwYce6Qj03Ugs01bTCeyvuD/pwhJD0UdkxY+r5Uy9iTh5W5e SKhuFCQJ518poxTKjPdtEBsw7HH1WegPLjsLPOQcX1L4namoFhJdHkFAUN96YGZieeiS71PmRXk9d GhwpVxiFTTqz7BHMffRP5Nsqm1oEiq805XmRqvjAaee2/EEJU7ZPa2reEWJHZwlNeqHfCAvXlWcN5 if8GU0O+g==; 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 1dIxSS-0005G8-M4; Thu, 08 Jun 2017 13:26:41 +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: Thu, 8 Jun 2017 15:25:31 +0200 Message-Id: <20170608132609.32662-7-hch@lst.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170608132609.32662-1-hch@lst.de> References: <20170608132609.32662-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 --- 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..638aea814b94 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -31,6 +31,8 @@ #include #include +#define IOMMU_MAPPING_ERROR (~(dma_addr_t)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,