From patchwork Mon Sep 21 17:17:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 7233191 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 232B4BEEC1 for ; Mon, 21 Sep 2015 17:19:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 382FF206EF for ; Mon, 21 Sep 2015 17:19:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2A60A206E2 for ; Mon, 21 Sep 2015 17:19:00 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ze4hV-00009w-Bd; Mon, 21 Sep 2015 17:16:25 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ze4hT-0008UT-BP for linux-arm-kernel@lists.infradead.org; Mon, 21 Sep 2015 17:16:23 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0758628; Mon, 21 Sep 2015 10:16:05 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.203.153]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 777783F308; Mon, 21 Sep 2015 10:15:59 -0700 (PDT) From: Andre Przywara To: "David S. Miller" Subject: [PATCH] sparc(64)/iommu: fixup iommu_tbl_range_alloc() types Date: Mon, 21 Sep 2015 18:17:09 +0100 Message-Id: <1442855829-11245-1-git-send-email-andre.przywara@arm.com> X-Mailer: git-send-email 2.5.1 In-Reply-To: <55FC49B8.3020100@arm.com> References: <55FC49B8.3020100@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150921_101623_409114_4519A82F X-CRM114-Status: GOOD ( 14.33 ) X-Spam-Score: -6.9 (------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sparclinux@vger.kernel.org, Joerg Roedel , linux-kernel@vger.kernel.org, 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With DMA_ERROR_CODE now being dma_addr_t in most architectures, it turned out that iommu_tbl_range_alloc (defined in lib/iommu-common.c) is actually using a wrong return type. This was easily fixed in a previous patch, but now the types in the callers do not match anymore. This patch fixes the obvious mismatches to allow sane comparisons with the error return value. Compile-tested on sparc, sparc64, x86, ARM, arm64. Signed-off-by: Andre Przywara --- Hi David, as promised my first naive try on fixing the callers of iommu_tbl_range_alloc() as well. This goes on top of the return type fix I sent on Friday. Please let me know if that makes sense or whether I am looking in the totally wrong direction. Cheers, Andre. arch/sparc/kernel/iommu.c | 5 +++-- arch/sparc/kernel/ldc.c | 5 +++-- arch/sparc/kernel/pci_sun4v.c | 7 ++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/arch/sparc/kernel/iommu.c b/arch/sparc/kernel/iommu.c index 5320689..7d04a87 100644 --- a/arch/sparc/kernel/iommu.c +++ b/arch/sparc/kernel/iommu.c @@ -157,7 +157,7 @@ static inline iopte_t *alloc_npages(struct device *dev, struct iommu *iommu, unsigned long npages) { - unsigned long entry; + dma_addr_t entry; entry = iommu_tbl_range_alloc(dev, &iommu->tbl, npages, NULL, (unsigned long)(-1), 0); @@ -476,7 +476,8 @@ static int dma_4u_map_sg(struct device *dev, struct scatterlist *sglist, IO_PAGE_SIZE) >> IO_PAGE_SHIFT; base_shift = iommu->tbl.table_map_base >> IO_PAGE_SHIFT; for_each_sg(sglist, s, nelems, i) { - unsigned long paddr, npages, entry, out_entry = 0, slen; + unsigned long paddr, npages, slen; + dma_addr_t entry, out_entry = 0; iopte_t *base; slen = s->length; diff --git a/arch/sparc/kernel/ldc.c b/arch/sparc/kernel/ldc.c index 1ae5eb1..41e79cb 100644 --- a/arch/sparc/kernel/ldc.c +++ b/arch/sparc/kernel/ldc.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -1949,11 +1950,11 @@ static u64 make_cookie(u64 index, u64 pgsz_code, u64 page_offset) static struct ldc_mtable_entry *alloc_npages(struct ldc_iommu *iommu, unsigned long npages) { - long entry; + dma_addr_t entry; entry = iommu_tbl_range_alloc(NULL, &iommu->iommu_map_table, npages, NULL, (unsigned long)-1, 0); - if (unlikely(entry < 0)) + if (unlikely(entry == DMA_ERROR_CODE)) return NULL; return iommu->page_table + entry; diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c index d2fe57d..f86902f 100644 --- a/arch/sparc/kernel/pci_sun4v.c +++ b/arch/sparc/kernel/pci_sun4v.c @@ -136,7 +136,7 @@ static void *dma_4v_alloc_coherent(struct device *dev, size_t size, struct iommu *iommu; struct page *page; void *ret; - long entry; + dma_addr_t entry; int nid; size = IO_PAGE_ALIGN(size); @@ -242,7 +242,7 @@ static dma_addr_t dma_4v_map_page(struct device *dev, struct page *page, unsigned long i, base_paddr; u32 bus_addr, ret; unsigned long prot; - long entry; + dma_addr_t entry; iommu = dev->archdata.iommu; @@ -361,7 +361,8 @@ static int dma_4v_map_sg(struct device *dev, struct scatterlist *sglist, IO_PAGE_SIZE) >> IO_PAGE_SHIFT; base_shift = iommu->tbl.table_map_base >> IO_PAGE_SHIFT; for_each_sg(sglist, s, nelems, i) { - unsigned long paddr, npages, entry, out_entry = 0, slen; + unsigned long paddr, npages, slen; + dma_addr_t entry, out_entry = 0; slen = s->length; /* Sanity check */