From patchwork Wed Oct 11 14:01:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 115558 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp795681qgn; Wed, 11 Oct 2017 07:02:30 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCQD3H6Mb08wkUZeOTFj/+7rGJqOxisFOGIBw5cotaeGREqVjvEXUiiXI+Bzea7D47xYeZe X-Received: by 10.98.141.138 with SMTP id p10mr16650245pfk.283.1507730549944; Wed, 11 Oct 2017 07:02:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507730549; cv=none; d=google.com; s=arc-20160816; b=UFnbuiJ13inWNtryC9VmWZ/HNH3xQxk8mkRqdueTCnrFb/vJkcUdfLw17MZf7OAYy7 XQWQvGZXP4j2w8GN06d4FnRbHZwpqTlO0xZoDtzE8IhlepYB246I7ngDqFaMZWlPL8vf 85dRENVLIrtpWhd3CS3BpSAzi24ut02aOTQLa818C9N33x6cVRd8YFn+OwFaElJrDYIe H3Jkhjx0Egb7Ak4iGH8rhswW7EOt3znAYqQcVi6e3+vkeCfnBl/DcYHP1uNYHvQvR++e 2rDI/zUaMWodlTVExJ/Jl9P0HxknSfTx3WmJCXGhXvUI2b15k0/aHb4Az05+p1voNdsL EAgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=IHGyYGPRyfS+rIQw2za2sadIpNuylmODR6prA6AgEwE=; b=os0Ht4YPc6Pj983jncwmNUzzpNBFxokX6W+I5ydJK0mKWg/d/ZYu4usR9pHR3i67Bb ygCjet9Wzv+n52ZWmAxRZaah7GvW8WGCziLCZWmuTZ/AAc7iZRzRcXr5+gdvPsvVEMUH zZB/O0223AzDSlKYpIJACIxRRHB3lv4HzNMo+eS5+nrOpB4ti49fw6M4kl3Yp1I29KQc ZI6NFZyrkrgcvGReIpTE1PjLEnL5XuHIrfPESpGd6VD2LhrZ66U9/c3f283XofawUi/2 6QgaP4EZZg367OVRNqWVLZwPScKegRv4g41GcyjGMN/zC8fi8o07h9u75XuLYNx71vFQ Og4A== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y76si2270493pfd.136.2017.10.11.07.02.29; Wed, 11 Oct 2017 07:02:29 -0700 (PDT) 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 S1757482AbdJKOC0 (ORCPT + 27 others); Wed, 11 Oct 2017 10:02:26 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:52604 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751691AbdJKOCY (ORCPT ); Wed, 11 Oct 2017 10:02:24 -0400 Received: from wuerfel.lan ([95.208.190.237]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0MdFJL-1dkTqT1gdn-00ITsr; Wed, 11 Oct 2017 16:01:46 +0200 From: Arnd Bergmann To: Vinod Koul , Maxime Coquelin , Alexandre Torgue Cc: Arnd Bergmann , Dan Williams , Pierre-Yves MORDRET , "M'boumba Cedric Madianga" , dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] dmaengine: stm32-mdma: avoid 64-bit division Date: Wed, 11 Oct 2017 16:01:31 +0200 Message-Id: <20171011140144.3746128-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:gDAi/RaQsC3OYHAkfz/saLOAqPN3QbyeWv37uk63+CoGO7FGYja d+wl4nqePiK7Hwt8iGdZbXR7UkaYqMXCXvV//NS7yZlRnIorx2Xer/T25R5+lCgFDNOYsM7 GCDoTPsZUdMNjjKaadwUwYcWw/4Ib1CJuay8F/yB1YvGg71U8ZjjpgoMVauJ2lIzOnpm3/0 vJUre0igmbzRcpqussUZg== X-UI-Out-Filterresults: notjunk:1; V01:K0:1BNQkuC0Lhg=:b8ubLJGQ1k899CwlvMnltW nPCZXlCKs8mDlHdQhcEDueVSXxNA+7APXECE8pSpiDVtIIGvqI+qRpQWClWqYA/hzoyazrKkb C8EaQN3jS87WcD8mE6+dkVgmKelFebk0cp8HjT7ODmL+we35QMklKBWqH6nGB6tQtQCIIPVq+ jVKNv3PRcy0WdFr4A4zOgHCJZVumVOoq6c4OZfQ0QpAZLch81cUqKGHfEtkOVaO1ery5k1uh3 rmUehEu8kthJyzLti85n06a2wRJgLGlWObFuWF6y9dE0Cq3N1dbuVVOCWpfuvj9KZo8pNOqLq eoweYh31fcr6eh5sNLURC/MA5PRcNalB9qTPdWDXSNqawfz+idUqKn+xXspf+CxnQ9Cpfu0Ms CJPBOmj11dLzlhaZE8VWOwk9LNnzeuYqfI0LYmTrYY0f4/vib2/7JeX3FI+ulGoi9Gyi7NJ+W KiZ9EOapa0NRDzkKU9jOZEGxpkPZT9tUW0OTGn0eq6cjVW15ye8Qk6QDfOj0jjysblUdV0DfV 4m/LhNw+vMhKURyZPPmX4fk2ZxTEQbBJ+ddk+DgyzThcCQKYcoZdjJTK0va7gPP7AcIIpw7Os IdUjjoBGAdFDtkfXCbS1VlKFTYUwKn9gt9EOxqvr0x2oi0ppy/cvmpzCvVZAV6hv9BcGnav2s uL7H+QTVRLuiOyRycD5z1B1ltRRnMSB6MWlGl8Bvmx47Mw1/HTYNSVSBhI+/+vARnurLh7MuA ogXLOUyuZBMWeeQA2Vnu7LYNgo7VYqgMb2Rycw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When building with a 64-bit dma_addr_t, we run into a link error: drivers/dma/stm32-mdma.o: In function `stm32_mdma_prep_dma_memcpy': stm32-mdma.c:(.text+0x16a3): undefined reference to `__umoddi3' Using a 64-bit division here is way too expensive, since the divisor is a known power-of-two value in reality. This moves the modulo operation into stm32_mdma_get_max_width(), where the compiler can optimize out that code, and we can use a 32-bit division to be on the safe side. Fixes: a4ffb13c8946 ("dmaengine: Add STM32 MDMA driver") Signed-off-by: Arnd Bergmann --- drivers/dma/stm32-mdma.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) -- 2.9.0 diff --git a/drivers/dma/stm32-mdma.c b/drivers/dma/stm32-mdma.c index 0db59a7e80e0..55151c2c9fae 100644 --- a/drivers/dma/stm32-mdma.c +++ b/drivers/dma/stm32-mdma.c @@ -387,7 +387,9 @@ static int stm32_mdma_get_width(struct stm32_mdma_chan *chan, } } -static enum dma_slave_buswidth stm32_mdma_get_max_width(u32 buf_len, u32 tlen) +static enum dma_slave_buswidth stm32_mdma_get_max_width(u32 buf_len, + u32 addr, + u32 tlen) { enum dma_slave_buswidth max_width = DMA_SLAVE_BUSWIDTH_8_BYTES; @@ -398,6 +400,9 @@ static enum dma_slave_buswidth stm32_mdma_get_max_width(u32 buf_len, u32 tlen) break; } + if (addr % max_width) + max_width = DMA_SLAVE_BUSWIDTH_1_BYTE; + return max_width; } @@ -567,7 +572,7 @@ static int stm32_mdma_set_xfer_param(struct stm32_mdma_chan *chan, ctcr |= STM32_MDMA_CTCR_DBURST((ilog2(dst_best_burst))); /* Set memory data size */ - src_addr_width = stm32_mdma_get_max_width(buf_len, tlen); + src_addr_width = stm32_mdma_get_max_width(buf_len, 0, tlen); chan->mem_width = src_addr_width; src_bus_width = stm32_mdma_get_width(chan, src_addr_width); if (src_bus_width < 0) @@ -611,7 +616,7 @@ static int stm32_mdma_set_xfer_param(struct stm32_mdma_chan *chan, ctcr |= STM32_MDMA_CTCR_SBURST((ilog2(src_best_burst))); /* Set memory data size */ - dst_addr_width = stm32_mdma_get_max_width(buf_len, tlen); + dst_addr_width = stm32_mdma_get_max_width(buf_len, 0, tlen); chan->mem_width = dst_addr_width; dst_bus_width = stm32_mdma_get_width(chan, dst_addr_width); if (dst_bus_width < 0) @@ -956,9 +961,7 @@ stm32_mdma_prep_dma_memcpy(struct dma_chan *c, dma_addr_t dest, dma_addr_t src, ctcr |= STM32_MDMA_CTCR_TLEN((tlen - 1)); /* Set source best burst size */ - max_width = stm32_mdma_get_max_width(len, tlen); - if (src % max_width) - max_width = DMA_SLAVE_BUSWIDTH_1_BYTE; + max_width = stm32_mdma_get_max_width(len, src, tlen); src_bus_width = stm32_mdma_get_width(chan, max_width); max_burst = tlen / max_width; @@ -971,9 +974,7 @@ stm32_mdma_prep_dma_memcpy(struct dma_chan *c, dma_addr_t dest, dma_addr_t src, STM32_MDMA_CTCR_SINCOS(src_bus_width); /* Set destination best burst size */ - max_width = stm32_mdma_get_max_width(len, tlen); - if (dest % max_width) - max_width = DMA_SLAVE_BUSWIDTH_1_BYTE; + max_width = stm32_mdma_get_max_width(len, dest, tlen); dst_bus_width = stm32_mdma_get_width(chan, max_width); max_burst = tlen / max_width; @@ -1014,9 +1015,7 @@ stm32_mdma_prep_dma_memcpy(struct dma_chan *c, dma_addr_t dest, dma_addr_t src, STM32_MDMA_MAX_BLOCK_LEN); /* Set source best burst size */ - max_width = stm32_mdma_get_max_width(len, tlen); - if (src % max_width) - max_width = DMA_SLAVE_BUSWIDTH_1_BYTE; + max_width = stm32_mdma_get_max_width(len, src, tlen); src_bus_width = stm32_mdma_get_width(chan, max_width); max_burst = tlen / max_width; @@ -1030,9 +1029,7 @@ stm32_mdma_prep_dma_memcpy(struct dma_chan *c, dma_addr_t dest, dma_addr_t src, STM32_MDMA_CTCR_SINCOS(src_bus_width); /* Set destination best burst size */ - max_width = stm32_mdma_get_max_width(len, tlen); - if (dest % max_width) - max_width = DMA_SLAVE_BUSWIDTH_1_BYTE; + max_width = stm32_mdma_get_max_width(len, dest, tlen); dst_bus_width = stm32_mdma_get_width(chan, max_width); max_burst = tlen / max_width;