From patchwork Tue Jan 26 09:31:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101092 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp1846063lbb; Tue, 26 Jan 2016 01:33:00 -0800 (PST) X-Received: by 10.98.14.81 with SMTP id w78mr32738242pfi.26.1453800780435; Tue, 26 Jan 2016 01:33:00 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n83si804361pfa.183.2016.01.26.01.33.00; Tue, 26 Jan 2016 01:33:00 -0800 (PST) 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; 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 S934155AbcAZJc6 (ORCPT + 30 others); Tue, 26 Jan 2016 04:32:58 -0500 Received: from mout.kundenserver.de ([212.227.17.24]:63266 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933384AbcAZJcy (ORCPT ); Tue, 26 Jan 2016 04:32:54 -0500 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue102) with ESMTPA (Nemesis) id 0M57wk-1aBWqO09ug-00zHIx; Tue, 26 Jan 2016 10:32:22 +0100 From: Arnd Bergmann To: Jon Mason , Dave Jiang , Allen Hubbe Cc: linux-arm-kernel@lists.infradead.org, Arnd Bergmann , linux-ntb@googlegroups.com, linux-kernel@vger.kernel.org Subject: [PATCH] ntb: perf test: fix address space confusion Date: Tue, 26 Jan 2016 10:31:45 +0100 Message-Id: <1453800729-2501235-1-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 X-Provags-ID: V03:K0:gG2uuOWKcrIBd0iiBS0qyS88ayWoumnHcoffkQPvNI4Ul4vAUng GnOeHYDRA4hSllQUEbV0XPVKIttu4dAHa6b35Bt3iTj61rIU+aUU7GYwi5a8MCUqfv+xBOH GFMrD+POVg/82IlHm0kmAVRgh6PWEpDxSh3Ls30ulG9rAUQ3yvcu7tebByj3n7EWCZPMpqA d5GVKoVQv6PPaWYSthVzA== X-UI-Out-Filterresults: notjunk:1; V01:K0:1eYGGuX678w=:aXZUctBNDg5bTRgBJdKBki TkS4U4NS5sYMyTQlrmzmDFgDFesxMPuxDXgZ0Nyz9HxJlK1PTsi7u1C/QVEuUIibipokdb6Aj 2JHs9TyE7ttLpau4L9kAn/NS1gFSMgPu0Q7YXDnkhvBgvAO9sOnue8xaHn4NcqvUv84vDoebH uQReAnuw2gX0G38IUgcdZlQuRVVsdZfiQofFnFplXQqPfGqLo3xEkYadm3ScdeO7nJqjXNMhF NUs68kfPzPW/qg1xOc750+E/2QoY3DxSCLJ1o0Df52xxxWHvw5eaQWWyPA9Tk3dkH/sLFMugZ zhc0kUDR46y/YdBF5SueI3uL2ExGJfjpalC2qXwkTBwFq48Q1rP9YVR/G8TaWOHKjU7e9ELFq ejTRTTkv4WQNwsc5TJLSBoh2wftrP6X4NRtffWIKmc0+ONQTZEO09l+mIM+piD3foUfCRYHro Nwy4Vf8cvPCPq8/InyuGy4QhrmwFSFcrxuugxW4bPPWecXBLOMeiz3PB13GTsbyqCFo4HbzIt /PIceH5x/WasuU21A3XVVjAsYL14d6TAdYmQnNJsulswOlQHFoPWmhihrItfrGfwGVXtaRhbT eF9VVE8nAzuGO3ZaS0AXFN0/hW/9vGoNxetVqvv2vjiqnmHzvNKx/ToqNOonkEO2UJfVhlAdd ctkj5eC7yPIXOjlzeZABI/IXV5HJ9S4JOgUlZ4Qx1VH2Gvi+gnD7brDes6Ss9otMOUUg= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ntb driver assigns between pointers an __iomem tokens, and also casts them to 64-bit integers, which results in compiler warnings on 32-bit systems: drivers/ntb/test/ntb_perf.c: In function 'perf_copy': drivers/ntb/test/ntb_perf.c:213:10: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] vbase = (u64)(u64 *)mw->vbase; ^ drivers/ntb/test/ntb_perf.c:214:14: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] dst_vaddr = (u64)(u64 *)dst; ^ This adds __iomem annotations where needed and changes the temporary variables to iomem pointers to avoid casting them to u64. I did not see the problem in linux-next earlier, but it show showed up in 4.5-rc1. Signed-off-by: Arnd Bergmann Fixes: 8a7b6a778a85 ("ntb: ntb perf tool") --- drivers/ntb/test/ntb_perf.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) -- 2.7.0 Acked-by: Dave Jiang diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c index c8a37ba4b4f9..6bdc1e7b7503 100644 --- a/drivers/ntb/test/ntb_perf.c +++ b/drivers/ntb/test/ntb_perf.c @@ -178,7 +178,7 @@ static void perf_copy_callback(void *data) atomic_dec(&pctx->dma_sync); } -static ssize_t perf_copy(struct pthr_ctx *pctx, char *dst, +static ssize_t perf_copy(struct pthr_ctx *pctx, char __iomem *dst, char *src, size_t size) { struct perf_ctx *perf = pctx->perf; @@ -189,7 +189,8 @@ static ssize_t perf_copy(struct pthr_ctx *pctx, char *dst, dma_cookie_t cookie; size_t src_off, dst_off; struct perf_mw *mw = &perf->mw; - u64 vbase, dst_vaddr; + void __iomem *vbase; + void __iomem *dst_vaddr; dma_addr_t dst_phys; int retries = 0; @@ -204,14 +205,14 @@ static ssize_t perf_copy(struct pthr_ctx *pctx, char *dst, } device = chan->device; - src_off = (size_t)src & ~PAGE_MASK; - dst_off = (size_t)dst & ~PAGE_MASK; + src_off = (uintptr_t)src & ~PAGE_MASK; + dst_off = (uintptr_t __force)dst & ~PAGE_MASK; if (!is_dma_copy_aligned(device, src_off, dst_off, size)) return -ENODEV; - vbase = (u64)(u64 *)mw->vbase; - dst_vaddr = (u64)(u64 *)dst; + vbase = mw->vbase; + dst_vaddr = dst; dst_phys = mw->phys_addr + (dst_vaddr - vbase); unmap = dmaengine_get_unmap_data(device->dev, 1, GFP_NOWAIT); @@ -261,13 +262,13 @@ err_get_unmap: return 0; } -static int perf_move_data(struct pthr_ctx *pctx, char *dst, char *src, +static int perf_move_data(struct pthr_ctx *pctx, char __iomem *dst, char *src, u64 buf_size, u64 win_size, u64 total) { int chunks, total_chunks, i; int copied_chunks = 0; u64 copied = 0, result; - char *tmp = dst; + char __iomem *tmp = dst; u64 perf, diff_us; ktime_t kstart, kstop, kdiff; @@ -324,7 +325,7 @@ static int ntb_perf_thread(void *data) struct perf_ctx *perf = pctx->perf; struct pci_dev *pdev = perf->ntb->pdev; struct perf_mw *mw = &perf->mw; - char *dst; + char __iomem *dst; u64 win_size, buf_size, total; void *src; int rc, node, i; @@ -364,7 +365,7 @@ static int ntb_perf_thread(void *data) if (buf_size > MAX_TEST_SIZE) buf_size = MAX_TEST_SIZE; - dst = (char *)mw->vbase; + dst = (char __iomem *)mw->vbase; atomic_inc(&perf->tsync); while (atomic_read(&perf->tsync) != perf->perf_threads)