From patchwork Tue Jan 3 15:55:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 710519 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 ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ttJTw0tQcz9t0v for ; Wed, 4 Jan 2017 02:56:52 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ctSjFkrw"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3ttJTv6tZvzDqFS for ; Wed, 4 Jan 2017 02:56:51 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ctSjFkrw"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-pg0-x243.google.com (mail-pg0-x243.google.com [IPv6:2607:f8b0:400e:c05::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3ttJSQ6jfSzDqDx for ; Wed, 4 Jan 2017 02:55:34 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ctSjFkrw"; dkim-atps=neutral Received: by mail-pg0-x243.google.com with SMTP id g1so33915312pgn.0 for ; Tue, 03 Jan 2017 07:55:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ma+Ms1zkWs5Ad/dYS4XLtTMRHsxVHWduLMhtW84y+W8=; b=ctSjFkrwWeNisyONdQU3qU0A6Do79iYh/iE11Np6bg73W0iLiExJ9c131Jx58Ey4eg 4lKCe/YacYGmZtztMPVbqt8T4qunarL2f7T7eri1VUL5L6j90HhrRBvY7+FxzOLWGEYR 5UicFcVoS5XMOJcmJYnmN/DXyMPJNbNj1tmV3VE72PHmp8FVg3bn7sXVTY/XTQqSq4Ig ymmhP944G/9zTzG8b9cMULmsCggYnTcf2M9aSm6LfNPc4ud2vWMo6CLx4iLfYAQ9zFKb LmrBFgnmPR1YQl4QIWf3CE2MnFmGTNKd7qo3gsVD2I6cO3MZKDg8oZxIlwAb/62SaC8g NQew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ma+Ms1zkWs5Ad/dYS4XLtTMRHsxVHWduLMhtW84y+W8=; b=jlU706Hok7gs9auMzkx6X5pLkmS+BM4W0cOux6pDmN7BNvgsl9bS8CxuMgMk2IBrqu W1xWplZRHYFI5McvSOBwLAI4ycSyKeuyzDlVSswfpNG0+STyEmCzCr4biaGu3vFnocUv unrWaIQg9HRSrS/uu3RLM757EZx4MVg7glNfhP/Ylbu+iyyU1mAIf3UhXmVtWHGI0JI3 GGfG/5JRqokPi3TpWA6cwZLNeZPfB6MIIhHyDcp2MNZO9GZAT0yDb/H1WD9o6O/Q4Aje z6ZDNk94/tvZK2tBdi3jrCzA8pICZxPEwWKk+uN6SX0bWsZj2179mtKQFIVYfYV+HZRM g5WA== X-Gm-Message-State: AIkVDXJQ0fQJrBh9wbufHUaSXsSfPc2x24d7byACU/MS2i48+uIYJkS32amhr/uRTvMa1w== X-Received: by 10.98.12.138 with SMTP id 10mr57466395pfm.82.1483458932915; Tue, 03 Jan 2017 07:55:32 -0800 (PST) Received: from roar.au.ibm.com ([203.221.7.176]) by smtp.gmail.com with ESMTPSA id o68sm140818762pfb.42.2017.01.03.07.55.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Jan 2017 07:55:32 -0800 (PST) From: Nicholas Piggin To: Michael Ellerman Subject: [PATCH] powerpc: fix pgtable pmd cache init Date: Wed, 4 Jan 2017 01:55:17 +1000 Message-Id: <20170103155517.24347-1-npiggin@gmail.com> X-Mailer: git-send-email 2.11.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Scott Wood , linuxppc-dev@lists.ozlabs.org, "Aneesh Kumar K . V" , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Commit 9b081e10805cd ("powerpc: port 64 bits pgtable_cache to 32 bits") mixed up PMD_INDEX_SIZE and PMD_CACHE_INDEX a couple of times. This resulted in 64s/hash/4k configs to panic at boot with a false positive error check. Fix that and simplify error handling by moving the check to the caller. Fixes: 9b081e10805cd ("powerpc: port 64 bits pgtable_cache to 32 bits") Cc: Christophe Leroy Cc: Aneesh Kumar K.V Cc: Scott Wood Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Nicholas Piggin --- arch/powerpc/mm/hugetlbpage.c | 6 +----- arch/powerpc/mm/init-common.c | 11 +++-------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index 289df38fb7e0..f21f6b907d99 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -810,12 +810,8 @@ static int __init hugetlbpage_init(void) * if we have pdshift and shift value same, we don't * use pgt cache for hugepd. */ - if (pdshift > shift) { + if (pdshift > shift) pgtable_cache_add(pdshift - shift, NULL); - if (!PGT_CACHE(pdshift - shift)) - panic("hugetlbpage_init(): could not create " - "pgtable cache for %d bit pagesize\n", shift); - } #if defined(CONFIG_PPC_FSL_BOOK3E) || defined(CONFIG_PPC_8xx) else if (!hugepte_cache) { /* diff --git a/arch/powerpc/mm/init-common.c b/arch/powerpc/mm/init-common.c index a175cd82ae8c..1a3be5ae1d07 100644 --- a/arch/powerpc/mm/init-common.c +++ b/arch/powerpc/mm/init-common.c @@ -80,6 +80,8 @@ void pgtable_cache_add(unsigned shift, void (*ctor)(void *)) new = kmem_cache_create(name, table_size, align, 0, ctor); kfree(name); pgtable_cache[shift - 1] = new; + if (!new) + panic("Could not allocate pgtable cache for order %d", shift); pr_debug("Allocated pgtable cache for order %d\n", shift); } @@ -88,7 +90,7 @@ void pgtable_cache_init(void) { pgtable_cache_add(PGD_INDEX_SIZE, pgd_ctor); - if (PMD_INDEX_SIZE && !PGT_CACHE(PMD_INDEX_SIZE)) + if (PMD_CACHE_INDEX && !PGT_CACHE(PMD_CACHE_INDEX)) pgtable_cache_add(PMD_CACHE_INDEX, pmd_ctor); /* * In all current configs, when the PUD index exists it's the @@ -97,11 +99,4 @@ void pgtable_cache_init(void) */ if (PUD_INDEX_SIZE && !PGT_CACHE(PUD_INDEX_SIZE)) pgtable_cache_add(PUD_INDEX_SIZE, pud_ctor); - - if (!PGT_CACHE(PGD_INDEX_SIZE)) - panic("Couldn't allocate pgd cache"); - if (PMD_INDEX_SIZE && !PGT_CACHE(PMD_INDEX_SIZE)) - panic("Couldn't allocate pmd pgtable caches"); - if (PUD_INDEX_SIZE && !PGT_CACHE(PUD_INDEX_SIZE)) - panic("Couldn't allocate pud pgtable caches"); }