From patchwork Mon Jun 23 05:05:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Salter X-Patchwork-Id: 4399311 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C82369F433 for ; Mon, 23 Jun 2014 05:09:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EB8DD202A1 for ; Mon, 23 Jun 2014 05:09:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (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 061E6201F4 for ; Mon, 23 Jun 2014 05:09:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WywSF-0003h2-AQ; Mon, 23 Jun 2014 05:06:07 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WywSC-0003gD-JS for linux-arm-kernel@lists.infradead.org; Mon, 23 Jun 2014 05:06:05 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5N55USb005493 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 23 Jun 2014 01:05:30 -0400 Received: from deneb.redhat.com (ovpn-113-76.phx2.redhat.com [10.3.113.76]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5N55Tva020722; Mon, 23 Jun 2014 01:05:29 -0400 From: Mark Salter To: Catalin Marinas , Will Deacon Subject: [PATCH] arm64: make CONFIG_ZONE_DMA user settable Date: Mon, 23 Jun 2014 01:05:24 -0400 Message-Id: <1403499924-11214-1-git-send-email-msalter@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140622_220604_697581_9363BFD1 X-CRM114-Status: GOOD ( 15.97 ) X-Spam-Score: -5.0 (-----) Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Mark Salter X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, T_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 Commit 19e7640d1f (arm64: Replace ZONE_DMA32 with ZONE_DMA) moves support for 32-bit DMA addressing into ZONE_DMA and renames CONFIG_ZONE_DMA32 to CONFIG_ZONE_DMA. Commit 2d5a5612bc (arm64: Limit the CMA buffer to 32-bit if ZONE_DMA) forces the CMA buffer to be 32-bit addressable if CONFIG_ZONE_DMA is defined. These two patches pose a problem for platforms which have no 32-bit addressable DRAM. If CONFIG_ZONE_DMA is turned on for such platforms, CMA is unable to reserve a buffer for allocations. CONFIG_ZONE_DMA is not user settable however, so there is no way to turn it off without editing arch/arm64/Kconfig. Even if one edits Kconfig to turn off CONFIG_ZONE_DMA, the kernel fails to build with such a config: arch/arm64/mm/init.c: In function ‘zone_sizes_init’: arch/arm64/mm/init.c:76:13: error: ‘ZONE_DMA’ undeclared (first use in this function) zone_size[ZONE_DMA] = max_dma - min; ^ This patch makes CONFIG_ZONE_DMA user settable and fixes the kernel build when it is turned off. Signed-off-by: Mark Salter --- arch/arm64/Kconfig | 11 ++++++++--- arch/arm64/mm/init.c | 8 ++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index c8b1d0b..f669597 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -99,9 +99,6 @@ config GENERIC_CSUM config GENERIC_CALIBRATE_DELAY def_bool y -config ZONE_DMA - def_bool y - config ARCH_DMA_ADDR_T_64BIT def_bool y @@ -211,6 +208,14 @@ config HOTPLUG_CPU Say Y here to experiment with turning CPUs off and on. CPUs can be controlled through /sys/devices/system/cpu. +config ZONE_DMA + bool "32-bit DMA memory allocation" + def_bool y + help + 32-bit DMA memory allocation supports devices limited to 32-bit + DMA addressing to allocate within the first 4GiB of address space. + Disable if no such devices will be used. + source kernel/Kconfig.preempt config HZ diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index f43db8a..c5415e2 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -69,12 +69,14 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max) memset(zone_size, 0, sizeof(zone_size)); /* 4GB maximum for 32-bit only capable devices */ - if (IS_ENABLED(CONFIG_ZONE_DMA)) { +#ifdef CONFIG_ZONE_DMA + { unsigned long max_dma_phys = (unsigned long)(dma_to_phys(NULL, DMA_BIT_MASK(32)) + 1); max_dma = max(min, min(max, max_dma_phys >> PAGE_SHIFT)); zone_size[ZONE_DMA] = max_dma - min; } +#endif zone_size[ZONE_NORMAL] = max - max_dma; memcpy(zhole_size, zone_size, sizeof(zhole_size)); @@ -86,10 +88,12 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max) if (start >= max) continue; - if (IS_ENABLED(CONFIG_ZONE_DMA) && start < max_dma) { +#ifdef CONFIG_ZONE_DMA + if (start < max_dma) { unsigned long dma_end = min(end, max_dma); zhole_size[ZONE_DMA] -= dma_end - start; } +#endif if (end > max_dma) { unsigned long normal_end = min(end, max);