From patchwork Mon Aug 19 10:19:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 2846426 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A7FABBF546 for ; Mon, 19 Aug 2013 10:21:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 892BE20384 for ; Mon, 19 Aug 2013 10:21:19 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 08384202E5 for ; Mon, 19 Aug 2013 10:21:15 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VBMaG-0006N3-GS; Mon, 19 Aug 2013 10:21:12 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VBMaE-0001QM-2q; Mon, 19 Aug 2013 10:21:10 +0000 Received: from mail-oa0-f44.google.com ([209.85.219.44]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VBMa7-0001P7-8e for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2013 10:21:07 +0000 Received: by mail-oa0-f44.google.com with SMTP id l20so5633361oag.3 for ; Mon, 19 Aug 2013 03:20:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0hCzqnmEz1e6jKZ+QRAO07ZEbt3OjV5aMOA+K1oW3tM=; b=Gj90LfEBo4FM+8b8OwZ2840EoQ9+4gQZyNXPTFtu1Ek1rEZrYelD6A7lM69dwvI8F7 4u8xvkSCx+SAd61TNUc/rDvJ4+ZNrMVEuIKDGFhKmHCBatwPvA7GmeexqGFtr+1U9HjW VztbJrWPEpga6c+bqh6TUemBPs/4TU3BqC/34Nhn1lFWsgaKLibUft3rB8Vn0O2+2ZOT N4VnH6CzexTMr/yXje7AZnWfcZAM5MsmdypuL8PwCw4RuW3RApzAGFg+Q97NJSC8SY5Q lTISaruqe4+p7FvwkpRbkwL3gkduQmay5UYqtkUF9QqdhR5/RKik/TPz2Yqy4zkcg1DR YQ4g== X-Gm-Message-State: ALoCoQku264FZ4D10/nt82o2smKE+Xrirl5jLwRBJsGZL6i72kcMTbYNu/9LwsKH0fcx6rs3RL/I X-Received: by 10.60.51.7 with SMTP id g7mr11427372oeo.6.1376907640533; Mon, 19 Aug 2013 03:20:40 -0700 (PDT) Received: from slackpad.drs.calxeda.com (g224198001.adsl.alicedsl.de. [92.224.198.1]) by mx.google.com with ESMTPSA id ya5sm15756249obc.1.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 Aug 2013 03:20:40 -0700 (PDT) From: Andre Przywara To: peter.pearse@arm.com, linus.walleij@linaro.org, linux@arm.linux.org.uk Subject: [PATCH v2] DMA: fix AMBA PL08x compilation issue with 64bit DMA address type Date: Mon, 19 Aug 2013 12:19:28 +0200 Message-Id: <1376907568-18689-1-git-send-email-andre.przywara@linaro.org> X-Mailer: git-send-email 1.7.12.1 In-Reply-To: <20130815211515.GF23006@n2100.arm.linux.org.uk> References: <20130815211515.GF23006@n2100.arm.linux.org.uk> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130819_062103_331803_66FA4151 X-CRM114-Status: GOOD ( 12.33 ) X-Spam-Score: -2.6 (--) Cc: vinod.koul@intel.com, linux-arm-kernel@lists.infradead.org, rob.herring@calxeda.com, patches@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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=-7.0 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 When dma_addr_t is 64 bits long, compilation of the AMBA PL08x DMA driver breaks due to a missing 64bit%8bit modulo operation. Looking more closely the divisor in these operations can only be 1, 2 or 4, so the full featured '%' modulo operation is overkill and can be replaced with simple bit masking. Change from v1: Replace open-coded function with existing IS_ALIGNED macro and use a macro around that to avoid a line becoming too long. Signed-off-by: Andre Przywara Acked-by: Vinod Koul --- drivers/dma/amba-pl08x.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c index bce5fbf..bff41d4 100644 --- a/drivers/dma/amba-pl08x.c +++ b/drivers/dma/amba-pl08x.c @@ -133,6 +133,8 @@ struct pl08x_bus_data { u8 buswidth; }; +#define IS_BUS_ALIGNED(bus) IS_ALIGNED((bus)->addr, (bus)->buswidth) + /** * struct pl08x_phy_chan - holder for the physical channels * @id: physical index to this channel @@ -889,8 +891,8 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x, return 0; } - if ((bd.srcbus.addr % bd.srcbus.buswidth) || - (bd.dstbus.addr % bd.dstbus.buswidth)) { + if (!IS_BUS_ALIGNED(&bd.srcbus) || + !IS_BUS_ALIGNED(&bd.dstbus)) { dev_err(&pl08x->adev->dev, "%s src & dst address must be aligned to src" " & dst width if peripheral is flow controller", @@ -911,9 +913,9 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x, */ if (bd.remainder < mbus->buswidth) early_bytes = bd.remainder; - else if ((mbus->addr) % (mbus->buswidth)) { - early_bytes = mbus->buswidth - (mbus->addr) % - (mbus->buswidth); + else if (!IS_BUS_ALIGNED(mbus)) { + early_bytes = mbus->buswidth - + (mbus->addr & (mbus->buswidth - 1)); if ((bd.remainder - early_bytes) < mbus->buswidth) early_bytes = bd.remainder; } @@ -931,7 +933,7 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x, * Master now aligned * - if slave is not then we must set its width down */ - if (sbus->addr % sbus->buswidth) { + if (!IS_BUS_ALIGNED(sbus)) { dev_dbg(&pl08x->adev->dev, "%s set down bus width to one byte\n", __func__);