From patchwork Sat Feb 1 00:23:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 3564131 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 CC40DC02DC for ; Sat, 1 Feb 2014 00:24:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0FF0320255 for ; Sat, 1 Feb 2014 00:24:53 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 98C5820253 for ; Sat, 1 Feb 2014 00:24:51 +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 1W9ONo-0003Eu-NY; Sat, 01 Feb 2014 00:24:28 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W9ONm-00017f-BJ; Sat, 01 Feb 2014 00:24:26 +0000 Received: from smtp.codeaurora.org ([198.145.11.231]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W9ONh-00017B-Vi for linux-arm-kernel@lists.infradead.org; Sat, 01 Feb 2014 00:24:22 +0000 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 0781613EEFD; Sat, 1 Feb 2014 00:23:59 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id EE4DF13EFFB; Sat, 1 Feb 2014 00:23:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from lauraa-linux1.qualcomm.com (i-global252.qualcomm.com [199.106.103.252]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: lauraa@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 25B6013EEFD; Sat, 1 Feb 2014 00:23:58 +0000 (UTC) From: Laura Abbott To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] arm64: Align CMA sizes to PAGE_SIZE Date: Fri, 31 Jan 2014 16:23:54 -0800 Message-Id: <1391214234-23526-1-git-send-email-lauraa@codeaurora.org> X-Mailer: git-send-email 1.7.8.3 X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140131_192422_101933_A7A1D07E X-CRM114-Status: GOOD ( 13.83 ) X-Spam-Score: -2.5 (--) Cc: Will Deacon , Laura Abbott , Catalin Marinas 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-Virus-Scanned: ClamAV using ClamSMTP dma_alloc_from_contiguous takes number of pages for a size. Align up the dma size passed in to page size to avoid truncation and allocation failures on sizes less than PAGE_SIZE. Cc: Will Deacon Cc: Catalin Marinas Signed-off-by: Laura Abbott --- arch/arm64/mm/dma-mapping.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c index 864b256..be2696e 100644 --- a/arch/arm64/mm/dma-mapping.c +++ b/arch/arm64/mm/dma-mapping.c @@ -44,6 +44,8 @@ static void *arm64_swiotlb_alloc_coherent(struct device *dev, size_t size, flags |= GFP_DMA32; if (IS_ENABLED(CONFIG_CMA)) { unsigned long pfn; + + size = PAGE_ALIGN(size); pfn = dma_alloc_from_contiguous(dev, size >> PAGE_SHIFT, get_order(size)); if (!pfn)