Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1738003ybl; Thu, 9 Jan 2020 00:26:29 -0800 (PST) X-Google-Smtp-Source: APXvYqxFK4/H/hHnKKEMX+kxDmnmciVhC2k2r1H/7IRoxpy7/jUjDr60P0Ny3Ih92yCcmyHmF2pH X-Received: by 2002:a9d:6e98:: with SMTP id a24mr7197581otr.109.1578558389804; Thu, 09 Jan 2020 00:26:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578558389; cv=none; d=google.com; s=arc-20160816; b=yj3JZpqXuTxrY/v/r2pElL28Jn4dAE2NRhEQ0ZNDcJyvCjnwkNb9UjE5m6D4qwnFCJ vaE7shydOJNUC+Mvda/z4mYYBti6LqrzCfbm6n/qTFB0aIvVBa1zDmIn+rFWdDdNO/Ic 7kyoV1ozsTGgXoKQFtVdzxSP84XksX2JVz4O8eQNKb0SFzSMLRlZGmD+ZdPK4rcIyeey PGnTuFZXCvopG5St9mSJafDnQmnnbj/iiaAUaTVSL8ObltUkKnROpA7abkQNbbfs6NtV ZNTXSQj8uceWHUpB6CNde0XXq7ubGurZ/W9z/TJpevOYpEzosCDN+50snr9UsKndnuBX Pw4g== 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:dkim-signature; bh=Anq1hyH2aL9sk2xmmZjvLgbNttOZtDCALsnDzW0G9vQ=; b=Q8USBnltV+py42Lv98BsDrnriBx8kfrplFUlQ3InfwVsIAjE0xCPt0WW6aAFmo4lEm n+jz7UmpjjjhiToJ9Y7IK5YB/UA4cjhBRUcZb03DNl+vEhN82yAoudfs5OYu6HcftYBH NfgR2F6UriUfUDJwh5BpdcLdN+zqTXcoxskez51gXyzV8UyxlmDkleR/C2XqsF2wrBB5 1zpsg9VD9BcECjKRqWyyKQol5SkGTHJ2pZR3ew+B94bYbYCEbAzkL1loFmUrAOiq7MEP +0W7xFSj/BOOBpa1cPBE8CkK4q1tUrfSiWsWUjZ50trKFOIGOr8hExP0gyEddM2OBGWV aimw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=QrDDSHXz; 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 o12si3256069oie.150.2020.01.09.00.26.17; Thu, 09 Jan 2020 00:26:29 -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; dkim=pass header.i=@c-s.fr header.s=mail header.b=QrDDSHXz; 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 S1728479AbgAIIZa (ORCPT + 99 others); Thu, 9 Jan 2020 03:25:30 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:28347 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728431AbgAIIZ2 (ORCPT ); Thu, 9 Jan 2020 03:25:28 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 47tfLs30h8z9v3XQ; Thu, 9 Jan 2020 09:25:25 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=QrDDSHXz; dkim-adsp=pass; dkim-atps=neutral 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 Fju97S-s3mM8; Thu, 9 Jan 2020 09:25:25 +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 47tfLs1z8Vz9v3XM; Thu, 9 Jan 2020 09:25:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1578558325; bh=Anq1hyH2aL9sk2xmmZjvLgbNttOZtDCALsnDzW0G9vQ=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=QrDDSHXzPUf4RA7kKLqkxQv+PcjlDEH+aqqM2OiAQghychKnsJuIP/CI5KrHwcfTE Pio4ScfISdPCQPl7SEAeSyD+JPmm8EiVaOHyQusnnpuAIUoe8LMrcZsk9Aznr/lZdk blSPlUNPu7uif3nDAqZtYKITrflsOm8ZrgEDTxnw= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 451468B816; Thu, 9 Jan 2020 09:25:26 +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 J1S0I2ywjlUg; Thu, 9 Jan 2020 09:25:26 +0100 (CET) Received: from localhost.localdomain (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id F2AFE8B769; Thu, 9 Jan 2020 09:25:25 +0100 (CET) Received: by localhost.localdomain (Postfix, from userid 0) id 1327D63B8D; Thu, 9 Jan 2020 08:25:26 +0000 (UTC) Message-Id: <788378c6c3ba5c5298caab7c7f95e6c3c88244b8.1578558199.git.christophe.leroy@c-s.fr> In-Reply-To: <7b065c5be35726af4066cab238ee35cabceda1fa.1578558199.git.christophe.leroy@c-s.fr> References: <7b065c5be35726af4066cab238ee35cabceda1fa.1578558199.git.christophe.leroy@c-s.fr> From: Christophe Leroy Subject: [PATCH v3 2/2] powerpc/32: drop get_pteptr() To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Mike Rapoport Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Thu, 9 Jan 2020 08:25:26 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 8d30c14cab30 ("powerpc/mm: Rework I$/D$ coherency (v3)") and commit 90ac19a8b21b ("[POWERPC] Abolish iopa(), mm_ptov(), io_block_mapping() from arch/powerpc") removed the use of get_pteptr() outside of mm/pgtable_32.c In mm/pgtable_32.c, the only user of get_pteptr() is change_page_attr() which operates on kernel context and on lowmem pages only. Make virt_to_kpte() available outside of mm/mem.c and use it instead of get_pteptr(), and drop get_pteptr() Signed-off-by: Christophe Leroy --- v3: new --- arch/powerpc/include/asm/pgtable.h | 5 +++++ arch/powerpc/mm/mem.c | 5 ----- arch/powerpc/mm/pgtable_32.c | 39 ++------------------------------------ 3 files changed, 7 insertions(+), 42 deletions(-) diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index b5e358c0ea7e..25588edc7601 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -51,6 +51,11 @@ static inline pmd_t *pmd_ptr_k(unsigned long va) { return pmd_offset(pud_offset(pgd_offset_k(va), va), va); } + +static inline pte_t *virt_to_kpte(unsigned long vaddr) +{ + return pte_offset_kernel(pmd_ptr_k(vaddr), vaddr); +} #endif #include diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 942d41b88aa6..da6708a46ce9 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -65,11 +65,6 @@ pte_t *kmap_pte; EXPORT_SYMBOL(kmap_pte); pgprot_t kmap_prot; EXPORT_SYMBOL(kmap_prot); - -static inline pte_t *virt_to_kpte(unsigned long vaddr) -{ - return pte_offset_kernel(pmd_ptr_k(vaddr), vaddr); -} #endif pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c index 7d50cc01bbea..4e1e5237c16c 100644 --- a/arch/powerpc/mm/pgtable_32.c +++ b/arch/powerpc/mm/pgtable_32.c @@ -121,44 +121,9 @@ void __init mapin_ram(void) } } -/* Scan the real Linux page tables and return a PTE pointer for - * a virtual address in a context. - * Returns true (1) if PTE was found, zero otherwise. The pointer to - * the PTE pointer is unmodified if PTE is not found. - */ -static int -get_pteptr(struct mm_struct *mm, unsigned long addr, pte_t **ptep, pmd_t **pmdp) -{ - pgd_t *pgd; - pud_t *pud; - pmd_t *pmd; - pte_t *pte; - int retval = 0; - - pgd = pgd_offset(mm, addr & PAGE_MASK); - if (pgd) { - pud = pud_offset(pgd, addr & PAGE_MASK); - if (pud && pud_present(*pud)) { - pmd = pmd_offset(pud, addr & PAGE_MASK); - if (pmd_present(*pmd)) { - pte = pte_offset_map(pmd, addr & PAGE_MASK); - if (pte) { - retval = 1; - *ptep = pte; - if (pmdp) - *pmdp = pmd; - /* XXX caller needs to do pte_unmap, yuck */ - } - } - } - } - return(retval); -} - static int __change_page_attr_noflush(struct page *page, pgprot_t prot) { pte_t *kpte; - pmd_t *kpmd; unsigned long address; BUG_ON(PageHighMem(page)); @@ -166,10 +131,10 @@ static int __change_page_attr_noflush(struct page *page, pgprot_t prot) if (v_block_mapped(address)) return 0; - if (!get_pteptr(&init_mm, address, &kpte, &kpmd)) + kpte = virt_to_kpte(address); + if (!kpte) return -EINVAL; __set_pte_at(&init_mm, address, kpte, mk_pte(page, prot), 0); - pte_unmap(kpte); return 0; } -- 2.13.3