From patchwork Tue Aug 15 18:13:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 801706 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="lpOMxjP5"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xX0xP1WyCz9t3m for ; Wed, 16 Aug 2017 04:14:33 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=sII1uoElU29E98Gq1cQdDqkRhbqiR2d9aOi2rTZjV7Q=; b=lpOMxjP5LgtUk6ZHdXy9NUVBZw PWerU3zmy8sP260GKl1xkis25ic1DOY2VLGEyK6fhAVVBScfWat7VdEjC7GEKHRNwaumYDKV/fBHr rH6lTeJ16rlbRK6Wb12835O3oChuLriuIk7WGhoi/ZDzve4QSXs7XV85E0wFm6xUrLGH/2tD5NAow YhCDY5/b5xyvzR1NHhGc+qqFrTIFEZXxeiP0O2h4xB8hpyTcV2zQuOiAhyX5e/K0FbdFlosjP/vyR QeHRUdGtjUbc7/rCOm/unk4frXbI5eeREE2CrA2k75Tu3QsWiv7nwNr26aNgSYw8rLkonGNNUpIYR z4xU6VLg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dhgMJ-0007MV-Sw; Tue, 15 Aug 2017 18:14:31 +0000 Received: from smtprelay4.synopsys.com ([198.182.47.9] helo=smtprelay.synopsys.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dhgMF-0007IW-St for linux-snps-arc@lists.infradead.org; Tue, 15 Aug 2017 18:14:30 +0000 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 278B424E0CF8; Tue, 15 Aug 2017 11:14:09 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 09C8B277; Tue, 15 Aug 2017 11:14:09 -0700 (PDT) Received: from localhost.internal.synopsys.com (unknown [10.121.8.106]) by mailhost.synopsys.com (Postfix) with ESMTP id 2C9CE21E; Tue, 15 Aug 2017 11:14:06 -0700 (PDT) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org Subject: [PATCH 2/3] ARC: Decouple linux kernel memory address and link address Date: Tue, 15 Aug 2017 21:13:54 +0300 Message-Id: <20170815181355.29937-3-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170815181355.29937-1-Eugeniy.Paltsev@synopsys.com> References: <20170815181355.29937-1-Eugeniy.Paltsev@synopsys.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170815_111428_295138_51101B7C X-CRM114-Status: GOOD ( 13.06 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [198.182.47.9 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [198.182.47.9 listed in wl.mailspike.net] -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Vineet Gupta , Alexey Brodkin , linux-kernel@vger.kernel.org, Rob Herring , Eugeniy Paltsev MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org We faced with problem when we tried to utilize 1G DRAM by linux on HSDK. We can't use our usual kernel memory address (0x80000000) like on AXS103 because of DCCM memory bank located at exactly same address (0x80000000) But we can't simply move kernel memory address to another address (like 0x90000000) because IOC base address must be aligned to the size of the aperture as specified in the IOC size register. So we had to use 1G aligned address for kernel memory. We can't use 0x00000000 or 0x40000000 addresses because addresses lover then 0x80000000 are MMU-translated. We can't use 0xB0000000 address because we can define a volatile uncached region only from AUX_NON_VOLATILE_LIMIT to the 0xFFFFFFFF. (the end of region is hardcoded) So, the decision is to link kernel to 0x90000000, but use 0x80000000-0xBFFFFFFF memory region and reallocate DCCM in our platform code. This patch only makes possible to set kernel memory address not equal to kernel link address. Signed-off-by: Eugeniy Paltsev --- arch/arc/Kconfig | 5 +++++ arch/arc/include/asm/page.h | 2 +- arch/arc/mm/cache.c | 2 +- arch/arc/mm/init.c | 6 +++--- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index a545969..75e5276 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -430,6 +430,11 @@ config LINUX_LINK_BASE However some customers have peripherals mapped at this addr, so Linux needs to be scooted a bit. If you don't know what the above means, leave this setting alone. + +config KERNEL_RAM_BASE_ADDRESS + hex "Linux ram base address" + default LINUX_LINK_BASE + help This needs to match memory start address specified in Device Tree config HIGHMEM diff --git a/arch/arc/include/asm/page.h b/arch/arc/include/asm/page.h index 296c342..777f676 100644 --- a/arch/arc/include/asm/page.h +++ b/arch/arc/include/asm/page.h @@ -85,7 +85,7 @@ typedef pte_t * pgtable_t; */ #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT) -#define ARCH_PFN_OFFSET virt_to_pfn(CONFIG_LINUX_LINK_BASE) +#define ARCH_PFN_OFFSET virt_to_pfn(CONFIG_KERNEL_RAM_BASE_ADDRESS) #ifdef CONFIG_FLATMEM #define pfn_valid(pfn) (((pfn) - ARCH_PFN_OFFSET) < max_mapnr) diff --git a/arch/arc/mm/cache.c b/arch/arc/mm/cache.c index 383ff77..f303274 100644 --- a/arch/arc/mm/cache.c +++ b/arch/arc/mm/cache.c @@ -1113,7 +1113,7 @@ noinline void __init arc_ioc_setup(void) * For now we assume IOC aperture to cover all the memory used by the * kernel. */ - ap_base = CONFIG_LINUX_LINK_BASE; + ap_base = CONFIG_KERNEL_RAM_BASE_ADDRESS; if (ap_base % ap_size != 0) panic("IOC Aperture start must be aligned to the size of the aperture"); diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c index 8c9415e..f84cba2 100644 --- a/arch/arc/mm/init.c +++ b/arch/arc/mm/init.c @@ -26,7 +26,7 @@ pgd_t swapper_pg_dir[PTRS_PER_PGD] __aligned(PAGE_SIZE); char empty_zero_page[PAGE_SIZE] __aligned(PAGE_SIZE); EXPORT_SYMBOL(empty_zero_page); -static const unsigned long low_mem_start = CONFIG_LINUX_LINK_BASE; +static const unsigned long low_mem_start = CONFIG_KERNEL_RAM_BASE_ADDRESS; static unsigned long low_mem_sz; #ifdef CONFIG_HIGHMEM @@ -63,7 +63,7 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size) if (!low_mem_sz) { if (base != low_mem_start) - panic("CONFIG_LINUX_LINK_BASE != DT memory { }"); + panic("CONFIG_KERNEL_RAM_BASE_ADDRESS != DT memory { }"); low_mem_sz = size; in_use = 1; @@ -161,7 +161,7 @@ void __init setup_arch_memory(void) * We can't use the helper free_area_init(zones[]) because it uses * PAGE_OFFSET to compute the @min_low_pfn which would be wrong * when our kernel doesn't start at PAGE_OFFSET, i.e. - * PAGE_OFFSET != CONFIG_LINUX_LINK_BASE + * PAGE_OFFSET != CONFIG_KERNEL_RAM_BASE_ADDRESS */ free_area_init_node(0, /* node-id */ zones_size, /* num pages per zone */