Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2832165imm; Thu, 18 Oct 2018 23:57:04 -0700 (PDT) X-Google-Smtp-Source: ACcGV61vwoKvA3MJzwAV2a+aALIbkyoD9NovaI4ZHlZslB9si7c0DKfvhw31hTB2guILnTuAFl8O X-Received: by 2002:a62:cfc4:: with SMTP id b187-v6mr24631925pfg.249.1539932224201; Thu, 18 Oct 2018 23:57:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539932224; cv=none; d=google.com; s=arc-20160816; b=uerWdWYalgLF+U33muxAckMIkQ7EbwKPaJpx4yzx/YZmn7aAlbGkdobko6JqDwSER9 VV8t6U7S7wpSgnpoF7sxMhSNGgA20aDAr2uxHnf6lWdiF2v0nb/oXINUL4Wi0qy6seXU eWrnevwf27XLi5FvQX7Ux4DVpTVhMNmN1+vKmzLzNjJ4stP0wRaWVBucU6EXO+YhzVE2 vQgg8Ew+SlnBB9WqHNNg8K9qmG8qHi4LM24adrKPPi9lt+49UFtWAn3j2gGCTXqILg2I eo0Lal+Ev7M5asrg3DGXzLNe4Idd9s3mTm1PYij3e0l21/aE3gP4EA5n3RWcFCrXbVrh sDPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id; bh=wXNYM1pMUmChtar6Azz8Qus4pwcEOTs38dEBFtWGJPI=; b=bY9dzi/1BlErGBZF1AWcQht+/ZHXWJ7CdOwIvMdZpqUD0plq2pvCa/N/2ut6wnn/1Q jeq+wadsUrXD8S3hUsFcLojN60zfvcMNwPHCEQ1sOlIf7qNy6pfIdp6mcOaA1ZCGI6YC yxpYp6e4BTGwYBW3QlhUbqyegWt8z9GQvPjtrYiH8+bn2PFpO1Gy9beT5ne4DJ4x0NTM NMX8VpdDXXdL5kZ5mOVle9YgfT6Wv+KJ1c1d60TD6uHl9UPw2ySd2svKLvv9mIVikt+5 By9iN0ZWeq21xa8g2eOVruSdykm4MJst57rC1ekQBTe0DmchSR55EKVj0s5qQ/q1f0Sk MkjA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e3-v6si292378pls.214.2018.10.18.23.56.49; Thu, 18 Oct 2018 23:57:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727465AbeJSPAC (ORCPT + 99 others); Fri, 19 Oct 2018 11:00:02 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:45565 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727444AbeJSPAB (ORCPT ); Fri, 19 Oct 2018 11:00:01 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 42bxW747M0z9ttFV; Fri, 19 Oct 2018 08:55:15 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id XB7zlI4WAnkp; Fri, 19 Oct 2018 08:55:15 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 42bxW73gQhz9ttFM; Fri, 19 Oct 2018 08:55:15 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id B3D688B8DF; Fri, 19 Oct 2018 08:55:16 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id ABdT3OhF3fDy; Fri, 19 Oct 2018 08:55:16 +0200 (CEST) Received: from pc13168vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.231.2]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 999ED8B75B; Fri, 19 Oct 2018 08:55:16 +0200 (CEST) Received: by pc13168vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 6F2216F496; Fri, 19 Oct 2018 06:55:16 +0000 (UTC) Message-Id: <105426dc7153837ec3e2b643a96c54f4268f5422.1539931702.git.christophe.leroy@c-s.fr> In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v6 12/20] powerpc/mm: Enable 512k hugepage support with HW assistance on the 8xx To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Fri, 19 Oct 2018 06:55:16 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For using 512k pages with hardware assistance, the PTEs have to be spread every 128 bytes in the L2 table. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/hugetlb.h | 4 +++- arch/powerpc/mm/hugetlbpage.c | 13 +++++++++++++ arch/powerpc/mm/tlb_nohash.c | 3 +++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/hugetlb.h b/arch/powerpc/include/asm/hugetlb.h index e13843556414..b22f164216ad 100644 --- a/arch/powerpc/include/asm/hugetlb.h +++ b/arch/powerpc/include/asm/hugetlb.h @@ -75,7 +75,9 @@ static inline pte_t *hugepte_offset(hugepd_t hpd, unsigned long addr, unsigned long idx = 0; pte_t *dir = hugepd_page(hpd); -#ifndef CONFIG_PPC_FSL_BOOK3E +#ifdef CONFIG_PPC_8xx + idx = (addr & ((1UL << pdshift) - 1)) >> PAGE_SHIFT; +#elif !defined(CONFIG_PPC_FSL_BOOK3E) idx = (addr & ((1UL << pdshift) - 1)) >> hugepd_shift(hpd); #endif diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index d56d92783295..75856a5b476b 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -67,7 +67,11 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp, cachep = PGT_CACHE(PTE_T_ORDER); num_hugepd = 1 << (pshift - pdshift); } else { +#ifdef CONFIG_PPC_8xx + cachep = PGT_CACHE(PTE_SHIFT); +#else cachep = PGT_CACHE(pdshift - pshift); +#endif num_hugepd = 1; } @@ -333,8 +337,13 @@ static void free_hugepd_range(struct mmu_gather *tlb, hugepd_t *hpdp, int pdshif if (shift >= pdshift) hugepd_free(tlb, hugepte); else +#ifdef CONFIG_PPC_8xx + pgtable_free_tlb(tlb, hugepte, + get_hugepd_cache_index(PTE_SHIFT)); +#else pgtable_free_tlb(tlb, hugepte, get_hugepd_cache_index(pdshift - shift)); +#endif } static void hugetlb_free_pmd_range(struct mmu_gather *tlb, pud_t *pud, @@ -702,7 +711,11 @@ static int __init hugetlbpage_init(void) * use pgt cache for hugepd. */ if (pdshift > shift) +#ifdef CONFIG_PPC_8xx + pgtable_cache_add(PTE_SHIFT); +#else pgtable_cache_add(pdshift - shift); +#endif #if defined(CONFIG_PPC_FSL_BOOK3E) || defined(CONFIG_PPC_8xx) else pgtable_cache_add(PTE_T_ORDER); diff --git a/arch/powerpc/mm/tlb_nohash.c b/arch/powerpc/mm/tlb_nohash.c index 8ad7aab150b7..ae5d568e267f 100644 --- a/arch/powerpc/mm/tlb_nohash.c +++ b/arch/powerpc/mm/tlb_nohash.c @@ -97,6 +97,9 @@ struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT] = { .shift = 14, }, #endif + [MMU_PAGE_512K] = { + .shift = 19, + }, [MMU_PAGE_8M] = { .shift = 23, }, -- 2.13.3