From patchwork Mon Jul 22 12:44:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 169381 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7482328ilk; Mon, 22 Jul 2019 05:45:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqyx8TRGCDJrlKyjk2x8hAIPe3g5xxD3yPCnE970s0PZB0zgo4dz4p07Pa0e6Je/db2Z2Gy0 X-Received: by 2002:a17:902:6a87:: with SMTP id n7mr74183346plk.336.1563799527957; Mon, 22 Jul 2019 05:45:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563799527; cv=none; d=google.com; s=arc-20160816; b=qNpQMZSCoHX9zu5maHQj8HtPjHi4VUX8+OKm7uxNJL2IHzhF21liS6b1BNdz3XkY8K r2rfILadCMnsOBydvYMHGhAqnzUHKnBYIhF1NktIRD5JQG7MZZ8QVaNx+LszopEqXzVO 99Td5Q9YMNjw28gb9RxoUqc69lqpk3OVtx7Rz7HVsDM/1kxPKa888ljGxBajNqNEYVPB eckok+IyNuQ6ZUSf4uPQt4pGUJZLMToCzCMH15rTvYxD9Nb0eL/duPgKG09vLox1C4eh 59Rcq3fFCT6Bw73Qh05IonF6I4nprutACa9oYLvdKv9vBPBTWzmZ8FbTPM9g7eiuHqFr uqEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=0mQKlCffs1DNG7ZQ46ebI4DBnHcVVpejD8xRadfBowE=; b=B5AQ7fI/vcQ3JbTL39ZBqqkUA1EgoL+g2kOcerpUukvRDVC5CZEihBRGeqDTVGvPeO dWGytR5Z+jom4wnUViDd385ZyD0HDa2XKvUpfmcDuPA164ktCcNGCwYinNlHNy7D3fNb 17VGxvDOzuJeN0zqvIlH5zM/zMFfwv2f2G+NEZQNSonIG1wXeeejOLQR8W3sjQCm4j5I H8rZXNAWbymvL26TctFAsTjk8rE60+3bjeqEeyoVw//5Gljak1o0egA13gxDV5RYiLC/ Z98eSD+Z5uZyw+TLdjFpyeqiVx9ch1nhwV3CgKXiuPMqTPjYeCN3UWH8+uqyAiocOSQX R+EA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dmaengine-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=dmaengine-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q31si8450628pjc.33.2019.07.22.05.45.27; Mon, 22 Jul 2019 05:45:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dmaengine-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 dmaengine-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=dmaengine-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727510AbfGVMp1 (ORCPT + 3 others); Mon, 22 Jul 2019 08:45:27 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:57701 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728298AbfGVMp1 (ORCPT ); Mon, 22 Jul 2019 08:45:27 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MTRAS-1hzSlf0CgG-00TlMc; Mon, 22 Jul 2019 14:45:03 +0200 From: Arnd Bergmann To: Gustavo Pimentel , Vinod Koul Cc: Arnd Bergmann , Dan Williams , Andy Shevchenko , Russell King , Joao Pinto , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] [v2] dmaengine: dw-edma: fix unnecessary stack usage Date: Mon, 22 Jul 2019 14:44:43 +0200 Message-Id: <20190722124457.1093886-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:YYatoRsXSnmJhuS9zQ32arIsHlbbR5TwQvO540Kwug1HsFi8yk3 Kt52+hk3Bnc9QwDzzrM0zJ2Xf/TbeFMIaneIxkPz1aAJNiOIPNd0eRa0sxEPiP+XHO5kRHg m8DfUJ22fnSE1lSn5KnTavkhtkdXhIOdFPxc4FvDgo5p2/U3ynruupU01STAhoEKwvjkUu/ aOLbyfKc9JHFrOoAtahUA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:Xf7VlFbttRk=:P5pqY5XIS0AguTxoatrB85 6/Dv4kEp/zrxSBGkDC/zCEYr6cIX110dt4M/PUeWZQy6+FeTT3x/AKFEgKWyp6ndpQnCzhNuP H9rf8Y684jHk5sEhgtAM3DZ/lMd2BpCPoLw9D/P/d1XWAt+iQCWxHjLUYSQgsjNaPeN7Tyaw7 5mb4qSCU8e40YszKrlxxiD3ntWflUj1Cv+q8FU7W1AXhoaQ4AxuhvbbPYO44PO937PFKbuidR 1F47QvQqCAhn83EXGcQGa5EmYyu31pWbtI5+wPH7aoGA6nbbpJvQzyrm5+WO1r4jouJ7MoNSa JoPxppQZBmP7+wFPNWdoRPvpvsz6YfjZknEUaTlbQDY9bLPuWwvTvYmvHYWaBH9UnBXpjo2b0 RwTkRRr4nrgC7ZuGYlxTdmuRpJUG10ErU2Mwnw06qLB6BzlcAZeP18UlQ8dtUOlbdvdY9fCKr T7deGhGJ31Mb4iwx7B7qGBndvbvdZW7LIgsIbceYp4YYDXl/F7ACL3ONniD0ASWpBjP9DHdYR 7pzQ2OOApGUu5xI7UmPJFvE6tKa1cN92IR+zfeEKRlLY9ddFhsk0H3GKh8ZKhIeb+49SdXlTL /Bm0/yZZd/L7RzNYSdZCkqXnyDJJwuDql8xgR7FS2SR10muMoOOtZaHw3H8fZwzDiGxES2pu8 4jRqEK0Hu59ASnTVESHRmh8AuMkMBaIRx/78qfwl6eoAsS4OvpxZnUggXLKs4tuwriLAWd3TA oKZK5SY4Gecik5cjHfrU01E2q/zWqheZqoOVug== Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org Putting large constant data on the stack causes unnecessary overhead and stack usage: drivers/dma/dw-edma/dw-edma-v0-debugfs.c:285:6: error: stack frame size of 1376 bytes in function 'dw_edma_v0_debugfs_on' [-Werror,-Wframe-larger-than=] Mark the variable 'static const' in order for the compiler to move it into the .rodata section where it does no such harm. Fixes: 305aebeff879 ("dmaengine: Add Synopsys eDMA IP version 0 debugfs support") Signed-off-by: Arnd Bergmann --- v2: unchanged --- drivers/dma/dw-edma/dw-edma-v0-debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.0 Acked-by: Gustavo Pimentel diff --git a/drivers/dma/dw-edma/dw-edma-v0-debugfs.c b/drivers/dma/dw-edma/dw-edma-v0-debugfs.c index 3226f528cc11..5728b6fe938c 100644 --- a/drivers/dma/dw-edma/dw-edma-v0-debugfs.c +++ b/drivers/dma/dw-edma/dw-edma-v0-debugfs.c @@ -48,7 +48,7 @@ static struct { } lim[2][EDMA_V0_MAX_NR_CH]; struct debugfs_entries { - char name[24]; + const char *name; dma_addr_t *reg; }; From patchwork Mon Jul 22 12:44:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 169382 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7483030ilk; Mon, 22 Jul 2019 05:46:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqyjrYSSzU88j0Ajaw1iP15Ls247KoXmpgYUO8YiQo1LjKqzu21AJEle0adBfkWeg2rV3Oru X-Received: by 2002:aa7:82da:: with SMTP id f26mr78001pfn.82.1563799575211; Mon, 22 Jul 2019 05:46:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563799575; cv=none; d=google.com; s=arc-20160816; b=pMsGgwHU4heR4/zwow9UgI8VTI2qbd5+VWZYkHp4SMVormRZIXjhlCVX8rwObFUEfg DCU3Ap632ad8pbnrtlIK9WEdMIllS7qtUyFjTTuypgZO76wLgF3GImSmJR3pTPy2X9UF S0RP6dIrlRo6DCuSBjajZcOihP1PK5Pzq4Q6+KuSj1aHN+rjRz9we1ky4Ms7x5gcadd0 PhzNnyJ4iEyUjKj8xnipfCj0tTrZxHvHULhJ4Gn0XmxGcw38E2EC//JW1I7x43B+Ay1S DdIEQ6sqMFfSEv0vqTETovirApCNWrQhDOx0hgruIgkLQJDQkXetsc0W58TOfqM8Kof6 SiUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=nr157flIw/UoaJTRmIeQLI+LqXn+tGFavApgBrGZgQY=; b=rVohKqymJKpKXqpgh4n8/6Jp+WQ72Gw/jPJ42F7ExIo71oMZf3iQBFPfS0h49iORML /5E0E7P3KC9ogPO1E2IRZk9tCgZYszo4tzbm2DzbyIBPZuUQMMas2WaT4v9WAeSnE9Xk VNTiG86K/C5iLQ76wnnfG1B7Mg+bFIOgazNnJDkEUr9G/Es72Ujq8QTwpe7qkV/fbxGq F5qfwO+qR4sG1sUNpK3CHm9PacSBv7rEMWY0KrJFZ7UHImVVyVHL7i/CoVVkzwVb9pEq RIWSHbEmUi5AekKlZoIx6OOjDz0HNkSqpz3ZWgnLI6BSizN7q25bH8+xvhpqzM4RQHux /ddg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dmaengine-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=dmaengine-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1si10375548plf.410.2019.07.22.05.46.15; Mon, 22 Jul 2019 05:46:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dmaengine-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 dmaengine-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=dmaengine-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728034AbfGVMqO (ORCPT + 3 others); Mon, 22 Jul 2019 08:46:14 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:34029 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728839AbfGVMqO (ORCPT ); Mon, 22 Jul 2019 08:46:14 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MMGAg-1i6fPV2DsE-00JGyq; Mon, 22 Jul 2019 14:45:59 +0200 From: Arnd Bergmann To: Gustavo Pimentel , Vinod Koul Cc: Arnd Bergmann , Dan Williams , Andy Shevchenko , Russell King , Joao Pinto , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] [v2] dmaengine: dw-edma: fix __iomem type confusion Date: Mon, 22 Jul 2019 14:44:44 +0200 Message-Id: <20190722124457.1093886-2-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190722124457.1093886-1-arnd@arndb.de> References: <20190722124457.1093886-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:CUzC51gD/pkxLL6rYsN7M8PznQGFd5ynDXR2kYavwG45F9zD91i FyvlnwmEgAY3EVIM7aXOIfilGAVhlJDMzKvPy6m04fVLIyQUozZ1V22/X0URZqK7Q2Xm93o Pow5Rr7ap1DmGGKEOcSj8v2PwiKxSs0rnXrwRx7iZtHQVuPBzNXfXXUGTcOPn4nuCSDZ091 V0SJE9hLlSDvpXtiI+cwA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:KuWggqzc3/E=:CEP5ANgAb2P750zS6NP5oL tTzimiVBjXgBqjW1W2OSPQpTfZFlsH+Cq5wkCJz386WI3IgoGE4AhmK6a2EUQ8T1RpFi0GxTB 7NMyjXq3zrtD3X9CtmTiS/OsV88k88H5A7u75qPQWu6fFbvPR1BKl4WxweHzCpuOVG4Y6NJ9Q wvdyaHb8S1vlbXterhZDMqTUDcIpBk/4M1hKuiZOvKersb4DJ1LiTMuAvbwl/vU9IExm8Zbvp DHMKomysdumegGTsGCTFJwq66pPnktKwO5Hu9Lh8KEtqSIfhjO3WsR919ruRW5g/yj8SYDi1N yFQQL1gw5GkAbIKobOVF9Y4/ElOrFIXHh/Rz55xgPjSo0BAKjyeV1SiOo/VkGyj907WO+PyMJ zPCZ/8jSjd5J+YzwxPoDRmqi+5mQ9Ukn7RmpOTgQZKI5Uh6f97rI7enixOXszPQJoHYxBSqmC peL/BRVY30zIDkoa6srrC0aFNM5luyyGZObNaHhcA8FN+DOfgIYWsNMg+PkItJBHxbULm1NTD B74klrxJowpMo5gK4PnUz63hlBZSjbpgHgRWOt4VxVpf2prgW/hI4qKsiHNDu5OfG0kx01qfw HsL8YRtU99xCe2KeX2IHWHtJPihs2qKmMu4VxSTMoHaO1y7HArCB/UIIhStX+k1q7kqvNHoLT jng0juRefTEpHFIMWB8vG/45OU4Qmxb9ZDZVj4Z9gPI5NDhK8VYFc+Dntm0ecbAWN20cobay3 LbvLeJkfvMrVxhtLmSUjHEBGw7XYBnKAZugMgQ== Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org The new driver mixes up dma_addr_t and __iomem pointers, which results in warnings on some 32-bit architectures, like: drivers/dma/dw-edma/dw-edma-v0-core.c: In function '__dw_regs': drivers/dma/dw-edma/dw-edma-v0-core.c:28:9: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] return (struct dw_edma_v0_regs __iomem *)dw->rg_region.vaddr; Make it use __iomem pointers consistently here, and avoid using dma_addr_t for __iomem tokens altogether. A small complication here is the debugfs code, which passes an __iomem token as the private data for debugfs files, requiring the use of extra __force. Fixes: 7e4b8a4fbe2c ("dmaengine: Add Synopsys eDMA IP version 0 support") Link: https://lore.kernel.org/lkml/20190617131918.2518727-1-arnd@arndb.de/ Signed-off-by: Arnd Bergmann --- v2: whitespace fixes --- drivers/dma/dw-edma/dw-edma-core.h | 2 +- drivers/dma/dw-edma/dw-edma-pcie.c | 18 ++++++++-------- drivers/dma/dw-edma/dw-edma-v0-core.c | 10 ++++----- drivers/dma/dw-edma/dw-edma-v0-debugfs.c | 27 ++++++++++++------------ 4 files changed, 29 insertions(+), 28 deletions(-) -- 2.20.0 diff --git a/drivers/dma/dw-edma/dw-edma-core.h b/drivers/dma/dw-edma/dw-edma-core.h index b6cc90cbc9dc..4e5f9f6e901b 100644 --- a/drivers/dma/dw-edma/dw-edma-core.h +++ b/drivers/dma/dw-edma/dw-edma-core.h @@ -50,7 +50,7 @@ struct dw_edma_burst { struct dw_edma_region { phys_addr_t paddr; - dma_addr_t vaddr; + void __iomem *vaddr; size_t sz; }; diff --git a/drivers/dma/dw-edma/dw-edma-pcie.c b/drivers/dma/dw-edma/dw-edma-pcie.c index 4c96e1c948f2..dc85f55e1bb8 100644 --- a/drivers/dma/dw-edma/dw-edma-pcie.c +++ b/drivers/dma/dw-edma/dw-edma-pcie.c @@ -130,19 +130,19 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev, chip->id = pdev->devfn; chip->irq = pdev->irq; - dw->rg_region.vaddr = (dma_addr_t)pcim_iomap_table(pdev)[pdata->rg_bar]; + dw->rg_region.vaddr = pcim_iomap_table(pdev)[pdata->rg_bar]; dw->rg_region.vaddr += pdata->rg_off; dw->rg_region.paddr = pdev->resource[pdata->rg_bar].start; dw->rg_region.paddr += pdata->rg_off; dw->rg_region.sz = pdata->rg_sz; - dw->ll_region.vaddr = (dma_addr_t)pcim_iomap_table(pdev)[pdata->ll_bar]; + dw->ll_region.vaddr = pcim_iomap_table(pdev)[pdata->ll_bar]; dw->ll_region.vaddr += pdata->ll_off; dw->ll_region.paddr = pdev->resource[pdata->ll_bar].start; dw->ll_region.paddr += pdata->ll_off; dw->ll_region.sz = pdata->ll_sz; - dw->dt_region.vaddr = (dma_addr_t)pcim_iomap_table(pdev)[pdata->dt_bar]; + dw->dt_region.vaddr = pcim_iomap_table(pdev)[pdata->dt_bar]; dw->dt_region.vaddr += pdata->dt_off; dw->dt_region.paddr = pdev->resource[pdata->dt_bar].start; dw->dt_region.paddr += pdata->dt_off; @@ -158,17 +158,17 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev, pci_dbg(pdev, "Mode:\t%s\n", dw->mode == EDMA_MODE_LEGACY ? "Legacy" : "Unroll"); - pci_dbg(pdev, "Registers:\tBAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%pa, p=%pa)\n", + pci_dbg(pdev, "Registers:\tBAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%p, p=%pa)\n", pdata->rg_bar, pdata->rg_off, pdata->rg_sz, - &dw->rg_region.vaddr, &dw->rg_region.paddr); + dw->rg_region.vaddr, &dw->rg_region.paddr); - pci_dbg(pdev, "L. List:\tBAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%pa, p=%pa)\n", + pci_dbg(pdev, "L. List:\tBAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%p, p=%pa)\n", pdata->ll_bar, pdata->ll_off, pdata->ll_sz, - &dw->ll_region.vaddr, &dw->ll_region.paddr); + dw->ll_region.vaddr, &dw->ll_region.paddr); - pci_dbg(pdev, "Data:\tBAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%pa, p=%pa)\n", + pci_dbg(pdev, "Data:\tBAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%p, p=%pa)\n", pdata->dt_bar, pdata->dt_off, pdata->dt_sz, - &dw->dt_region.vaddr, &dw->dt_region.paddr); + dw->dt_region.vaddr, &dw->dt_region.paddr); pci_dbg(pdev, "Nr. IRQs:\t%u\n", dw->nr_irqs); diff --git a/drivers/dma/dw-edma/dw-edma-v0-core.c b/drivers/dma/dw-edma/dw-edma-v0-core.c index 8a3180ed49a6..97e3fd41c8a8 100644 --- a/drivers/dma/dw-edma/dw-edma-v0-core.c +++ b/drivers/dma/dw-edma/dw-edma-v0-core.c @@ -25,7 +25,7 @@ enum dw_edma_control { static inline struct dw_edma_v0_regs __iomem *__dw_regs(struct dw_edma *dw) { - return (struct dw_edma_v0_regs __iomem *)dw->rg_region.vaddr; + return dw->rg_region.vaddr; } #define SET(dw, name, value) \ @@ -192,13 +192,13 @@ u32 dw_edma_v0_core_status_abort_int(struct dw_edma *dw, enum dw_edma_dir dir) static void dw_edma_v0_core_write_chunk(struct dw_edma_chunk *chunk) { struct dw_edma_burst *child; - struct dw_edma_v0_lli *lli; - struct dw_edma_v0_llp *llp; + struct dw_edma_v0_lli __iomem *lli; + struct dw_edma_v0_llp __iomem *llp; u32 control = 0, i = 0; u64 sar, dar, addr; int j; - lli = (struct dw_edma_v0_lli *)chunk->ll_region.vaddr; + lli = chunk->ll_region.vaddr; if (chunk->cb) control = DW_EDMA_V0_CB; @@ -224,7 +224,7 @@ static void dw_edma_v0_core_write_chunk(struct dw_edma_chunk *chunk) i++; } - llp = (struct dw_edma_v0_llp *)&lli[i]; + llp = (void __iomem *)&lli[i]; control = DW_EDMA_V0_LLP | DW_EDMA_V0_TCB; if (!chunk->cb) control |= DW_EDMA_V0_CB; diff --git a/drivers/dma/dw-edma/dw-edma-v0-debugfs.c b/drivers/dma/dw-edma/dw-edma-v0-debugfs.c index 5728b6fe938c..42739508c0d8 100644 --- a/drivers/dma/dw-edma/dw-edma-v0-debugfs.c +++ b/drivers/dma/dw-edma/dw-edma-v0-debugfs.c @@ -14,7 +14,7 @@ #include "dw-edma-core.h" #define REGS_ADDR(name) \ - ((dma_addr_t *)®s->name) + ((void __force *)®s->name) #define REGISTER(name) \ { #name, REGS_ADDR(name) } @@ -40,11 +40,11 @@ static struct dentry *base_dir; static struct dw_edma *dw; -static struct dw_edma_v0_regs *regs; +static struct dw_edma_v0_regs __iomem *regs; static struct { - void *start; - void *end; + void __iomem *start; + void __iomem *end; } lim[2][EDMA_V0_MAX_NR_CH]; struct debugfs_entries { @@ -54,22 +54,23 @@ struct debugfs_entries { static int dw_edma_debugfs_u32_get(void *data, u64 *val) { + void __iomem *reg = (void __force __iomem *)data; if (dw->mode == EDMA_MODE_LEGACY && - data >= (void *)®s->type.legacy.ch) { - void *ptr = (void *)®s->type.legacy.ch; + reg >= (void __iomem *)®s->type.legacy.ch) { + void __iomem *ptr = ®s->type.legacy.ch; u32 viewport_sel = 0; unsigned long flags; u16 ch; for (ch = 0; ch < dw->wr_ch_cnt; ch++) - if (lim[0][ch].start >= data && data < lim[0][ch].end) { - ptr += (data - lim[0][ch].start); + if (lim[0][ch].start >= reg && reg < lim[0][ch].end) { + ptr += (reg - lim[0][ch].start); goto legacy_sel_wr; } for (ch = 0; ch < dw->rd_ch_cnt; ch++) - if (lim[1][ch].start >= data && data < lim[1][ch].end) { - ptr += (data - lim[1][ch].start); + if (lim[1][ch].start >= reg && reg < lim[1][ch].end) { + ptr += (reg - lim[1][ch].start); goto legacy_sel_rd; } @@ -86,7 +87,7 @@ static int dw_edma_debugfs_u32_get(void *data, u64 *val) raw_spin_unlock_irqrestore(&dw->lock, flags); } else { - *val = readl(data); + *val = readl(reg); } return 0; @@ -105,7 +106,7 @@ static void dw_edma_debugfs_create_x32(const struct debugfs_entries entries[], } } -static void dw_edma_debugfs_regs_ch(struct dw_edma_v0_ch_regs *regs, +static void dw_edma_debugfs_regs_ch(struct dw_edma_v0_ch_regs __iomem *regs, struct dentry *dir) { int nr_entries; @@ -288,7 +289,7 @@ void dw_edma_v0_debugfs_on(struct dw_edma_chip *chip) if (!dw) return; - regs = (struct dw_edma_v0_regs *)dw->rg_region.vaddr; + regs = dw->rg_region.vaddr; if (!regs) return; From patchwork Mon Jul 22 12:44:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 169383 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7483415ilk; Mon, 22 Jul 2019 05:46:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZDtPOsu3KZa7UwJ5VrnrQAhS70FVHkHFp/nhaq3pdgYb0pWE45SnuamKvTknx4lHr3zFZ X-Received: by 2002:a63:608c:: with SMTP id u134mr71228858pgb.274.1563799604302; Mon, 22 Jul 2019 05:46:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563799604; cv=none; d=google.com; s=arc-20160816; b=p4D8wfIeAO0KWxsVdqAfngYTMLfkxQY60ywm+4OtbIum6lk1vpHAL/6hoCnGWsHQSb HmZbltRSl/A6BQho2kun0RwpHnTgSIvBtLaPTgTAKme/6ha+14H21xvpJu0j/BXlejdy IbDu5zhwD6BCTgmCoI1o9Vm+6hemfurPHob/KIq324lBkeZogcYm+9bjcjG9DnhqznGx RcWZozlUsvk92oVK+4ngddGsylx422KzY0nymAWSilXAsWaOkQE914qMGG7EEz+pLXOy YhoyZWhrivXAsOsWFeHQeH0HkkWk+OuwVfFrpaEiQsUho+bG/Tc6h2UXJ3e6/U2VpljC 5jgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=zUpSPiawwv65Oz0jgp8PEGVXRN2FjX1K9acL/C/GoA8=; b=UufMYxvpMr0uB6tygPhZL5LSWK7uSAnsRVFGT7wYGoOezuQZd/S1rISqr322886ubD T8FVGBMxUBnn9QbTxT76S43slNBFyRKWqc9PTH36mqDOvXU0GkrxmkDti8epp5i1aB1L gL7hpSFeqL5vFXU652VaeN9ScZQa8jDenObYz0TCLwFiYVeUceAgrT6paFozVbhMoaCB h8k1FIPxxnpITEVpD/zuKD3ffJyVORu1a31fGuPyQD4YBnJT3P/ITJuePEk4nibZmbU5 UXTVi76XvreOUoZXmUnxOs1P6tgWJvjjEZBcT7QVZheS2P64TbU1WCL4RpwhM7tG7lG7 iCHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dmaengine-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=dmaengine-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3si9231917pgq.414.2019.07.22.05.46.44; Mon, 22 Jul 2019 05:46:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dmaengine-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 dmaengine-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=dmaengine-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728922AbfGVMqn (ORCPT + 3 others); Mon, 22 Jul 2019 08:46:43 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:45607 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726895AbfGVMqn (ORCPT ); Mon, 22 Jul 2019 08:46:43 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1M4K2r-1hpGix19KD-000MNv; Mon, 22 Jul 2019 14:46:18 +0200 From: Arnd Bergmann To: Gustavo Pimentel , Vinod Koul Cc: Arnd Bergmann , Dan Williams , Andy Shevchenko , Russell King , Joao Pinto , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] [v2] dmaengine: dw-edma: fix endianess confusion Date: Mon, 22 Jul 2019 14:44:45 +0200 Message-Id: <20190722124457.1093886-3-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190722124457.1093886-1-arnd@arndb.de> References: <20190722124457.1093886-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:d5Lm4PYixfA8pbB02g2GgIjlRZdQahOKJAn4tWmkzSjHCHZz+0c mGByyd10vU6PjkFtT1c9Tv8zXEsWOBlurLMYYOe42GCRa3RycR4Fs37aYZDPSiXmWn+Uu+y jv1BzF7UXgTBBv8JeWwEGrn15D6CtjU7Sh1iDVnb2VD2B5ZqQQ8/PBuFNJDPaDvbiQjMSdB 9GCuhCcNGKxdwrlC6eD+Q== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:rySnjGhQpRQ=:wCX8tZwzY2BNeINq7MDHz8 eUWe8HmswCc/zzGV8LbVpGXmOdN8AiOSUYnJ/nbNtrDJTJkGPC4OvD2O8mKTvWEY62iC+diqy DEYWROsD7mOAClAHGC7Vx6X9G7FqiEkAqTu2uNvkVwCWm3mjAT6iYuM6S+vKn56XXr6ZXtQWx YQZDeE1OfsTwjbH1b2aY51w88Tw8BvRgI0jZPr4uYOD2SB3cagIwaV2sLhno2KPwvwtt85oLE yus0TuRnN3ANz+EzbHQdUDV1xH28sOcN4S+JoqcdKmFeI9pLowxMW0XfCQNTPD6Mcv0Hz4t9x bIzmnNMCm4Yg3ULjB9KGlW02Erv9aelWqImrQlmDY/Q/w4op1YjS7L0asNeGiWI/hnCo61/Jw q3W/EqMUXL6GDxFdZLYh3EsKXhqZufsS3DlmQYiEpiaVzVec59sfrcDR88OfqsCIyt+NGzWbg SYrzk95YQgr9gssxV9wL/ujvECJ4tT6M49KjHCv4dFcQ/FXPMMHBtLwhEN5nYXoptuZXsMSaE Qg1lQ+FaW9c1CRN88DrMqxK6NrhaJ3SnHGkbZHIr9gDCk94CsWkgndUPYNHjhq2Xop98taXB8 ljnxDhYUrpyPA5xt0dZ0zw74ou+Ifzsme2o/CbblGO/t6D0C1d8+x7YjZD0nGRBzZPb3ewyev Z9IoZ0JI5XrwozWgfpigS83KIk8fzHiAT21na6CxnVeYx/8FGKkKy39ONRJVi8ytXxsk8wAse lljaNp6U10E0LI2vRY0A+2uG+jqcqFhgaJJ6eQ== Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org When building with 'make C=1', sparse reports an endianess bug: drivers/dma/dw-edma/dw-edma-v0-debugfs.c:60:30: warning: cast removes address space of expression drivers/dma/dw-edma/dw-edma-v0-debugfs.c:86:24: warning: incorrect type in argument 1 (different address spaces) drivers/dma/dw-edma/dw-edma-v0-debugfs.c:86:24: expected void const volatile [noderef] *addr drivers/dma/dw-edma/dw-edma-v0-debugfs.c:86:24: got void *[assigned] ptr drivers/dma/dw-edma/dw-edma-v0-debugfs.c:86:24: warning: incorrect type in argument 1 (different address spaces) drivers/dma/dw-edma/dw-edma-v0-debugfs.c:86:24: expected void const volatile [noderef] *addr drivers/dma/dw-edma/dw-edma-v0-debugfs.c:86:24: got void *[assigned] ptr drivers/dma/dw-edma/dw-edma-v0-debugfs.c:86:24: warning: incorrect type in argument 1 (different address spaces) drivers/dma/dw-edma/dw-edma-v0-debugfs.c:86:24: expected void const volatile [noderef] *addr drivers/dma/dw-edma/dw-edma-v0-debugfs.c:86:24: got void *[assigned] ptr The current code is clearly wrong, as it passes an endian-swapped word into a register function where it gets swapped again. Just pass the variables directly into lower_32_bits()/upper_32_bits(). Fixes: 7e4b8a4fbe2c ("dmaengine: Add Synopsys eDMA IP version 0 support") Link: https://lore.kernel.org/lkml/20190617131820.2470686-1-arnd@arndb.de/ Signed-off-by: Arnd Bergmann --- v2: remove unneeded local variables --- drivers/dma/dw-edma/dw-edma-v0-core.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) -- 2.20.0 Acked-by: Gustavo Pimentel diff --git a/drivers/dma/dw-edma/dw-edma-v0-core.c b/drivers/dma/dw-edma/dw-edma-v0-core.c index 97e3fd41c8a8..692de47b1670 100644 --- a/drivers/dma/dw-edma/dw-edma-v0-core.c +++ b/drivers/dma/dw-edma/dw-edma-v0-core.c @@ -195,7 +195,6 @@ static void dw_edma_v0_core_write_chunk(struct dw_edma_chunk *chunk) struct dw_edma_v0_lli __iomem *lli; struct dw_edma_v0_llp __iomem *llp; u32 control = 0, i = 0; - u64 sar, dar, addr; int j; lli = chunk->ll_region.vaddr; @@ -214,13 +213,11 @@ static void dw_edma_v0_core_write_chunk(struct dw_edma_chunk *chunk) /* Transfer size */ SET_LL(&lli[i].transfer_size, child->sz); /* SAR - low, high */ - sar = cpu_to_le64(child->sar); - SET_LL(&lli[i].sar_low, lower_32_bits(sar)); - SET_LL(&lli[i].sar_high, upper_32_bits(sar)); + SET_LL(&lli[i].sar_low, lower_32_bits(child->sar)); + SET_LL(&lli[i].sar_high, upper_32_bits(child->sar)); /* DAR - low, high */ - dar = cpu_to_le64(child->dar); - SET_LL(&lli[i].dar_low, lower_32_bits(dar)); - SET_LL(&lli[i].dar_high, upper_32_bits(dar)); + SET_LL(&lli[i].dar_low, lower_32_bits(child->dar)); + SET_LL(&lli[i].dar_high, upper_32_bits(child->dar)); i++; } @@ -232,9 +229,8 @@ static void dw_edma_v0_core_write_chunk(struct dw_edma_chunk *chunk) /* Channel control */ SET_LL(&llp->control, control); /* Linked list - low, high */ - addr = cpu_to_le64(chunk->ll_region.paddr); - SET_LL(&llp->llp_low, lower_32_bits(addr)); - SET_LL(&llp->llp_high, upper_32_bits(addr)); + SET_LL(&llp->llp_low, lower_32_bits(chunk->ll_region.paddr)); + SET_LL(&llp->llp_high, upper_32_bits(chunk->ll_region.paddr)); } void dw_edma_v0_core_start(struct dw_edma_chunk *chunk, bool first) @@ -242,7 +238,6 @@ void dw_edma_v0_core_start(struct dw_edma_chunk *chunk, bool first) struct dw_edma_chan *chan = chunk->chan; struct dw_edma *dw = chan->chip->dw; u32 tmp; - u64 llp; dw_edma_v0_core_write_chunk(chunk); @@ -262,9 +257,10 @@ void dw_edma_v0_core_start(struct dw_edma_chunk *chunk, bool first) SET_CH(dw, chan->dir, chan->id, ch_control1, (DW_EDMA_V0_CCS | DW_EDMA_V0_LLE)); /* Linked list - low, high */ - llp = cpu_to_le64(chunk->ll_region.paddr); - SET_CH(dw, chan->dir, chan->id, llp_low, lower_32_bits(llp)); - SET_CH(dw, chan->dir, chan->id, llp_high, upper_32_bits(llp)); + SET_CH(dw, chan->dir, chan->id, llp_low, + lower_32_bits(chunk->ll_region.paddr)); + SET_CH(dw, chan->dir, chan->id, llp_high, + upper_32_bits(chunk->ll_region.paddr)); } /* Doorbell */ SET_RW(dw, chan->dir, doorbell,