From patchwork Wed Oct 7 03:48:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Wood X-Patchwork-Id: 527100 X-Patchwork-Delegate: scottwood@freescale.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8B4D8140D95 for ; Wed, 7 Oct 2015 14:56:54 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 5574D1A0D70 for ; Wed, 7 Oct 2015 14:56:54 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1on0130.outbound.protection.outlook.com [157.56.110.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 8FE2B1A0142 for ; Wed, 7 Oct 2015 14:48:42 +1100 (AEDT) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=scottwood@freescale.com; Received: from snotra.am.freescale.net (192.88.168.49) by BY1PR03MB1483.namprd03.prod.outlook.com (10.162.210.141) with Microsoft SMTP Server (TLS) id 15.1.286.20; Wed, 7 Oct 2015 03:48:37 +0000 From: Scott Wood To: Subject: [PATCH v2 06/18] powerpc/fsl-booke-64: Don't limit ppc64_rma_size to one TLB entry Date: Tue, 6 Oct 2015 22:48:10 -0500 Message-ID: <1444189702-17241-7-git-send-email-scottwood@freescale.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1444189702-17241-1-git-send-email-scottwood@freescale.com> References: <1444189702-17241-1-git-send-email-scottwood@freescale.com> MIME-Version: 1.0 X-Originating-IP: [192.88.168.49] X-ClientProxiedBy: BLUPR08CA0034.namprd08.prod.outlook.com (10.141.200.14) To BY1PR03MB1483.namprd03.prod.outlook.com (25.162.210.141) X-Microsoft-Exchange-Diagnostics: 1; BY1PR03MB1483; 2:2tMakTRncn16hdWU2eGX+pHhSgKHmFSSw47/HtItRXfKFQan59E9pbLuLSoV+RqPKgM2aIi1DVnG1Tx+aQQBl4hQMSvzgc1pvUJpTbVUZl9QlaPav70h8xRCCamvAKevptusf5obrw2jz9mkNlhMQYYkEEngtnKm/voguIkiJJI=; 3:FAW63LuJVjaLu18wOkR1frhNB1UUij8FbWdqyeQ1J5Tw47w/NWgI3M4Za6NWySRA4TxOIvfBUq7PhoyjjuPm6im5IyB4Qo3aJ5PVt3BcE+emnOD5LT6kNNBGO7CYzsR35Jy3OnWJTNB0XX19esNV/g==; 25:vHUOjxj3Ul44FePk+BawlwIIeun6TZs8l/sFYAUbDROOPrH6p+oMooHcR3b9P9vqnE3iN0SDm8ZfSi5eqghg6UHRTR6hOlpbOmMcnayPecTr/3kt1P1tjP3LEv6tNJ/kTpUtbL9GCR22sA5FF43dsVXnV99zs/rr/vrooYuz/nUy/DbmK2Ds7HWwaZFM1h/JYdM9u7V4J9m1/VI5G3W//QTaXed2uFo1tjGU8aYS4WBDnSOZW/9iiZXN1ygwHIaih4TW6ngoiil+4/Vwsri1jQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR03MB1483; X-Microsoft-Exchange-Diagnostics: 1; BY1PR03MB1483; 20:YNZ33I/wHQHlp2eevHnBwQ712EhGsN9yPF5Mt1pOSEne0S50hx+lIWpird7msqnT4AorIzp51gWyNeDs27adsuFS42aHkjtc8HVZLig6OB/oA9ualcNjDpyXXQinmJQ5+rhqPNbdEbUPAmaQcHJsgCQehpdrrztqxrDbIfK1HthP03W/IXWDSwddwqJUSgUUQrg5WrljqyZIzePBpsPqzWYxPqxLI3I5JriBtdS+zr/n4rVRbrLLtJbof4kstmDjSIwMhzWp6Z7+5NvIo3h1G7vDTvKbb3EVain6UsUtRrV6m9kgLq3gdG/MqesF/nXhnqijl0Vs9pEX0Wxdxqrt9WrwI7ABJgXX/Fc1ImjeBStGv4muzMbAUJA64MF1ySxWsC8zLB+WOnLeQHuM34x6K2JBhqm+2LPUsB3/ScJcqHDGkWOulzjtn0VDR27TDsemHDhEgDhLhHMUqpMlRJl+7j7Qi4YM747bglRos+Bh8K0b1P0Pn2+Omr9+r+wRfOSO; 4:Xsxqqf5KitGFlsHwNFAzE24e1G6bKgk2jv22TL0kYfvYQG3SwPtgjb6duCxpXK2hXPNYSRV+JGDDy8N4YNwLpbSshGd/eAqijmvGSR0BrQvXRpsq+ySn8uPR/W//QByQQ1dk4CwVUfjtpBujndPS/xJAMw5FXKGcUGloltS4E6w6aKtE8bC5ls/uZLmNa9e1eMnD9M/Oar8Rw26zEAypkzhVbnDSHWW74pe4NFtjFXbTmv+bRXhSbJKtrVRoHVOTZyUEdMeyJ89YxEHk4f5lz9CHXb4eIDJUyTBN/mo9IHYirVFdqyEnI8+AdOmrer3M1In+Hfi6Y5hEGiYGiLeoLrVSl0iIuB5cgP3y20bspfc= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(3002001); SRVR:BY1PR03MB1483; BCL:0; PCL:0; RULEID:; SRVR:BY1PR03MB1483; X-Forefront-PRVS: 0722981D2A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(199003)(189002)(122386002)(19580395003)(5007970100001)(5003940100001)(189998001)(19580405001)(107886002)(105586002)(46102003)(106356001)(50466002)(77096005)(40100003)(2351001)(230783001)(110136002)(50986999)(64706001)(42186005)(87976001)(86362001)(5004730100002)(47776003)(5001960100002)(76176999)(229853001)(101416001)(50226001)(92566002)(5008740100001)(2950100001)(66066001)(33646002)(36756003)(81156007)(5001920100001)(97736004)(48376002)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY1PR03MB1483; H:snotra.am.freescale.net; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: freescale.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY1PR03MB1483; 23:YP9FWKUWPx4XeZHrgqj/S5ia1g/svrh4FnhFmlD4a?= =?us-ascii?Q?iLkMhWTFcJOCriHy3qL6KxggAaF8+uw4PBWqm1jX29JtRmETbuwixMIZxC1J?= =?us-ascii?Q?J6IeWgVWC3ZdkViAkEOZFpVwh7chain7vQKJgy4Y0+AmJKuh/MFnw2niQkk7?= =?us-ascii?Q?GxzQeowY5C6LYUrEO+2dra6oXlmDQTk54YQ6d/TwrC0xvnXg4FB5EtqWiYp2?= =?us-ascii?Q?nbyFg8+TuyTo8yEFysSZiyfY9PIAxfh1RD6R1ooN6FXUYDBBxuOO922EHY7w?= =?us-ascii?Q?AcKb/gKuSKk9Z9hIKLcjcDpA/fwaKbryH3MbfBM+EBloFhJ8VmDVlHOilAFe?= =?us-ascii?Q?4wlEb6gSX4g/dPhoJD98FyQxpGLNhyj90cTmSqcljdICmMRBEIHBNBN65+yi?= =?us-ascii?Q?QMhG744pite220snPOEFzU3nL5BPNVcKouNTo2/ntRWa1BuoK/C4k/rT0H2S?= =?us-ascii?Q?4v6xT7T35/rd6ek9WYFCmeQI7iBMwebZuuQqC42IosXAoqPOFQN+SRl8NJrA?= =?us-ascii?Q?BhH+k0wkK+80/WXNFlyaUGtdMEhlw+qWbIEnk8RzCCARtqNh5EBb2luLi4e2?= =?us-ascii?Q?7ssv2ModnbOEpBQ+hgTlh67yJlnn+gdGwrrnE08oEGn3pEJNofBcyhVOAhxU?= =?us-ascii?Q?BMIQjx/3DCwEqt+AB+V78TgaQ3xnaezG8+xJSZ1UY6NcY3O7dqAad+i1ckA9?= =?us-ascii?Q?A159Ne3ekm4OEj9GaZFWtizJwChJueEDGFdQuN23Cbf7lGp1x5AwMdLvI3fH?= =?us-ascii?Q?kz9VChsx6OpOXWc2ei+4odL3F+vtJksQcD7ngBMLyUX+v+hO0Rtk3WUm2m2e?= =?us-ascii?Q?FWKCVVA+rO3quzBVhLRoK1TlCju+NgXFSFEJ6OM7s8Pi1Dc8kOUfwSXK81OK?= =?us-ascii?Q?wmff5TDUm8B97IrYg4LpBY61WM5Kb9FN4B2lL1co2b58PatxFJxUe00aJYC5?= =?us-ascii?Q?rJDhSg6ByZ55unPL8viUDqTonyJeLMhspfhBaDRoTLfxAcDguI72/KGkkwUk?= =?us-ascii?Q?ua66ve7Y9QbXdkqqj9lSRXIs+iAxBafvHfxlzto098ERtnx6yK0SvI+Nz6ji?= =?us-ascii?Q?0XT3IxVWG3x0O4g+SItclYSlEyqKM4fib0KaZi3U0lYZ0SPob0OZsWsz4ZjY?= =?us-ascii?Q?QGNkupky5+hQiBUH0GYgNwiJbDfg2kJ?= X-Microsoft-Exchange-Diagnostics: 1; BY1PR03MB1483; 5:NO/yFfDW55L87qvt7BMdlLDIhVjlXR7tSree64KnB+9OjaWwc8tj6LkeN1u72s8wDoARMn87MUv+n6vU3RHbZOXhhUck7yKuw16vxVV++pl7BJFWwvdjCNiOkOGcAbZu35U7wIbUh1/Zxs67l8KpOg==; 24:YlAqVpqn1MWj6S8hpVRdfdHP1ZJcRELiRDv3ZHmMhWNi9VF6yKO+wljzIfMePbg5n2qcVBogB3YhcZINLoNfwcjcKJeGM6iqloNdpU2AwwQ=; 20:Ybb5pRe1f+rgLYhwjNG0XubfYgVGgliS35BLsO+BZoGuKDq8xTT21MIMeiWQOr9lOyiqSGtfWVeF3O5PfPlQcw== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Oct 2015 03:48:37.9820 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR03MB1483 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Scott Wood , Tiejun Chen , kexec@lists.infradead.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" This is required for kdump to work when loaded at at an address that does not fall within the first TLB entry -- which can easily happen because while the lower limit is enforced via reserved memory, which doesn't affect how much is mapped, the upper limit is enforced via a different mechanism that does. Thus, more TLB entries are needed than would normally be used, as the total memory to be mapped might not be a power of two. Signed-off-by: Scott Wood --- arch/powerpc/mm/fsl_booke_mmu.c | 22 +++++++++++++++------- arch/powerpc/mm/mmu_decl.h | 3 ++- arch/powerpc/mm/tlb_nohash.c | 24 +++++++++++++++++------- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/arch/powerpc/mm/fsl_booke_mmu.c b/arch/powerpc/mm/fsl_booke_mmu.c index 36d3c55..5eef7d7 100644 --- a/arch/powerpc/mm/fsl_booke_mmu.c +++ b/arch/powerpc/mm/fsl_booke_mmu.c @@ -178,7 +178,8 @@ unsigned long calc_cam_sz(unsigned long ram, unsigned long virt, } static unsigned long map_mem_in_cams_addr(phys_addr_t phys, unsigned long virt, - unsigned long ram, int max_cam_idx) + unsigned long ram, int max_cam_idx, + bool dryrun) { int i; unsigned long amount_mapped = 0; @@ -188,7 +189,9 @@ static unsigned long map_mem_in_cams_addr(phys_addr_t phys, unsigned long virt, unsigned long cam_sz; cam_sz = calc_cam_sz(ram, virt, phys); - preptlbcam(i, virt, phys, cam_sz, pgprot_val(PAGE_KERNEL_X), 0); + if (!dryrun) + preptlbcam(i, virt, phys, cam_sz, + pgprot_val(PAGE_KERNEL_X), 0); ram -= cam_sz; amount_mapped += cam_sz; @@ -196,6 +199,9 @@ static unsigned long map_mem_in_cams_addr(phys_addr_t phys, unsigned long virt, phys += cam_sz; } + if (dryrun) + return amount_mapped; + loadcam_multi(0, i, max_cam_idx); tlbcam_index = i; @@ -208,12 +214,12 @@ static unsigned long map_mem_in_cams_addr(phys_addr_t phys, unsigned long virt, return amount_mapped; } -unsigned long map_mem_in_cams(unsigned long ram, int max_cam_idx) +unsigned long map_mem_in_cams(unsigned long ram, int max_cam_idx, bool dryrun) { unsigned long virt = PAGE_OFFSET; phys_addr_t phys = memstart_addr; - return map_mem_in_cams_addr(phys, virt, ram, max_cam_idx); + return map_mem_in_cams_addr(phys, virt, ram, max_cam_idx, dryrun); } #ifdef CONFIG_PPC32 @@ -244,7 +250,7 @@ void __init adjust_total_lowmem(void) ram = min((phys_addr_t)__max_low_memory, (phys_addr_t)total_lowmem); i = switch_to_as1(); - __max_low_memory = map_mem_in_cams(ram, CONFIG_LOWMEM_CAM_NUM); + __max_low_memory = map_mem_in_cams(ram, CONFIG_LOWMEM_CAM_NUM, false); restore_to_as0(i, 0, 0, 1); pr_info("Memory CAM mapping: "); @@ -312,10 +318,12 @@ notrace void __init relocate_init(u64 dt_ptr, phys_addr_t start) n = switch_to_as1(); /* map a 64M area for the second relocation */ if (memstart_addr > start) - map_mem_in_cams(0x4000000, CONFIG_LOWMEM_CAM_NUM); + map_mem_in_cams(0x4000000, CONFIG_LOWMEM_CAM_NUM, + false); else map_mem_in_cams_addr(start, PAGE_OFFSET + offset, - 0x4000000, CONFIG_LOWMEM_CAM_NUM); + 0x4000000, CONFIG_LOWMEM_CAM_NUM, + false); restore_to_as0(n, offset, __va(dt_ptr), 1); /* We should never reach here */ panic("Relocation error"); diff --git a/arch/powerpc/mm/mmu_decl.h b/arch/powerpc/mm/mmu_decl.h index 27c3a2d..9f58ff4 100644 --- a/arch/powerpc/mm/mmu_decl.h +++ b/arch/powerpc/mm/mmu_decl.h @@ -141,7 +141,8 @@ extern void MMU_init_hw(void); extern unsigned long mmu_mapin_ram(unsigned long top); #elif defined(CONFIG_PPC_FSL_BOOK3E) -extern unsigned long map_mem_in_cams(unsigned long ram, int max_cam_idx); +extern unsigned long map_mem_in_cams(unsigned long ram, int max_cam_idx, + bool dryrun); extern unsigned long calc_cam_sz(unsigned long ram, unsigned long virt, phys_addr_t phys); #ifdef CONFIG_PPC32 diff --git a/arch/powerpc/mm/tlb_nohash.c b/arch/powerpc/mm/tlb_nohash.c index a7381fb..bb04e4d 100644 --- a/arch/powerpc/mm/tlb_nohash.c +++ b/arch/powerpc/mm/tlb_nohash.c @@ -648,7 +648,7 @@ static void early_init_this_mmu(void) if (map) linear_map_top = map_mem_in_cams(linear_map_top, - num_cams); + num_cams, false); } #endif @@ -746,10 +746,14 @@ void setup_initial_memory_limit(phys_addr_t first_memblock_base, * entries are supported though that may eventually * change. * - * on FSL Embedded 64-bit, we adjust the RMA size to match the - * first bolted TLB entry size. We still limit max to 1G even if - * the TLB could cover more. This is due to what the early init - * code is setup to do. + * on FSL Embedded 64-bit, usually all RAM is bolted, but with + * unusual memory sizes it's possible for some RAM to not be mapped + * (such RAM is not used at all by Linux, since we don't support + * highmem on 64-bit). We limit ppc64_rma_size to what would be + * mappable if this memblock is the only one. Additional memblocks + * can only increase, not decrease, the amount that ends up getting + * mapped. We still limit max to 1G even if we'll eventually map + * more. This is due to what the early init code is set up to do. * * We crop it to the size of the first MEMBLOCK to * avoid going over total available memory just in case... @@ -757,8 +761,14 @@ void setup_initial_memory_limit(phys_addr_t first_memblock_base, #ifdef CONFIG_PPC_FSL_BOOK3E if (mmu_has_feature(MMU_FTR_TYPE_FSL_E)) { unsigned long linear_sz; - linear_sz = calc_cam_sz(first_memblock_size, PAGE_OFFSET, - first_memblock_base); + unsigned int num_cams; + + /* use a quarter of the TLBCAM for bolted linear map */ + num_cams = (mfspr(SPRN_TLB1CFG) & TLBnCFG_N_ENTRY) / 4; + + linear_sz = map_mem_in_cams(first_memblock_size, num_cams, + true); + ppc64_rma_size = min_t(u64, linear_sz, 0x40000000); } else #endif