Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2173221imu; Thu, 29 Nov 2018 00:11:26 -0800 (PST) X-Google-Smtp-Source: AFSGD/XTHmyEzrpdRb1KpAq4SjFCS8aNMdmsoqOcNaVdR6CL0VJ8nWqCh5WlmYqGfwHCtsQWjijM X-Received: by 2002:a62:184e:: with SMTP id 75mr485150pfy.28.1543479086159; Thu, 29 Nov 2018 00:11:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543479086; cv=none; d=google.com; s=arc-20160816; b=laLpwedzCNHsuRQjRn4JshzdL7xb9iznMdIsPoFR6Fa81Yj8Ug4qEHqYTrYCplBHH4 MHWPlv2pnTz3ElQYfCAjG8tCyGMs6BbCC3Wdyyi1P8zXm9ATYmCxu3zsrtdxc625rvPJ OpjnM8W0qr8mz/WfbNCruny1HHxLYAVo35rwM49G7lixqkCmZlbsLVkH3oHq9JPm6XG2 XVScGrfuL5wlXnbv86jLhjgV4srs3qqD3A7vdiijW1hJ+/inZ9ibGcmKy0E2x4GSWi2H qZc5y92D25x+1tNzdFqEfTDAm8/51bB1pxIW4geVzhSHnJ+4gjpWVEegp2P+VGeKlY3k vX0g== 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=uLMd02EU/JbtmEwkprvGJenem9yFz5iFJc+dXoaVYlM=; b=DepUFKglHmWesG2CGQhmRpPoptBI9t+yzMnV9YxXuxNYXiCyPlVYPIpAFkyiY7kwxn cE7YMcZTaGjRRXf31PRApB96J5PwJpjMgGXl6OwZG7Rqur6/TbBjg+gZA5BpVB5O12oa qnGN8zdCNueFU41BC5OofzxLMZ+qtcYiSfZPXfAGAHT7S4eQDJqcLaF8P3y2R9wqeuid yphi/3+Vn3DSmII9n51xxTiXUu1HvxqEhmr0tJvGgmZ14vEuRRqEtI45dLo/93NkaN4l TusFaaT01dKojCTezpb4yTdSaaTOWehwZDdJ8gL10x79ytvHKHVHCeyCi0wjWtTia/6y +2Og== 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 y25si1370279pgl.226.2018.11.29.00.11.11; Thu, 29 Nov 2018 00:11:26 -0800 (PST) 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 S1728385AbeK2TPM (ORCPT + 99 others); Thu, 29 Nov 2018 14:15:12 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:40090 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727391AbeK2TPL (ORCPT ); Thu, 29 Nov 2018 14:15:11 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4359FB0058z9vGpG; Thu, 29 Nov 2018 09:10:38 +0100 (CET) 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 cLhJIE9RtZXO; Thu, 29 Nov 2018 09:10:37 +0100 (CET) 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 4359F96cgFz9vGnW; Thu, 29 Nov 2018 09:10:37 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id C343C8B890; Thu, 29 Nov 2018 09:10:38 +0100 (CET) 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 w_j-zok4fp9k; Thu, 29 Nov 2018 09:10:38 +0100 (CET) Received: from po14163vm.idsi0.si.c-s.fr (unknown [192.168.232.3]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 968BA8B762; Thu, 29 Nov 2018 09:10:38 +0100 (CET) Received: by po14163vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 4159B69AEA; Thu, 29 Nov 2018 08:10:38 +0000 (UTC) Message-Id: <00b47f8f30643550d38d21a7180cf3c8d918a012.1543478200.git.christophe.leroy@c-s.fr> In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v8 17/20] powerpc/8xx: Enable 512k hugepage support with HW assistance To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Thu, 29 Nov 2018 08:10:38 +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 | 10 +++++++++- arch/powerpc/mm/tlb_nohash.c | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/hugetlb.h b/arch/powerpc/include/asm/hugetlb.h index dfb8bf236586..62a0ca02ca7d 100644 --- a/arch/powerpc/include/asm/hugetlb.h +++ b/arch/powerpc/include/asm/hugetlb.h @@ -74,7 +74,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 bc97874d7c74..5f22f1d399b3 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -65,6 +65,9 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp, if (pshift >= pdshift) { cachep = PGT_CACHE(PTE_T_ORDER); num_hugepd = 1 << (pshift - pdshift); + } else if (IS_ENABLED(CONFIG_PPC_8xx)) { + cachep = PGT_CACHE(PTE_SHIFT); + num_hugepd = 1; } else { cachep = PGT_CACHE(pdshift - pshift); num_hugepd = 1; @@ -331,6 +334,9 @@ static void free_hugepd_range(struct mmu_gather *tlb, hugepd_t *hpdp, int pdshif if (shift >= pdshift) hugepd_free(tlb, hugepte); + else if (IS_ENABLED(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)); @@ -700,7 +706,9 @@ 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 && IS_ENABLED(CONFIG_PPC_8xx)) + pgtable_cache_add(PTE_SHIFT); + else if (pdshift > shift) pgtable_cache_add(pdshift - shift); #if defined(CONFIG_PPC_FSL_BOOK3E) || defined(CONFIG_PPC_8xx) else 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