Received: by 10.213.65.68 with SMTP id h4csp1674474imn; Thu, 15 Mar 2018 06:34:06 -0700 (PDT) X-Google-Smtp-Source: AG47ELuOG/QIVVZGZelrySai+uwJsSK1ukbO+wcttgKgz3L0CMldP1j5kxFpDdkrXWWhoNcQCUFt X-Received: by 10.98.58.20 with SMTP id h20mr5661220pfa.178.1521120846410; Thu, 15 Mar 2018 06:34:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521120846; cv=none; d=google.com; s=arc-20160816; b=DT7xpH2Q3b2WAAH91Jt+aQKHLpESqbt2d0z8+8fv2619RI2fHPylldqLNJ+ouDkZXe dMc7pBfVwBcGqZEMDdbkh+HeMImaOx4aHzX+XSkH3kKmDVWkY5M5H3pMKVQzA0/FK3px 46LAqfGLNR0yFqDH6IVdSJo01NdCKQBR90p+7Jye1XqtbRzxAFrTAIwm9lkBBgPIwEHp GiGGkIoBYcem5QhJx0M00Xjn24GvL7g1Kq72jfi2Rc1SKm80CGJEKb0i6f1/IokANcrV UCmSvTVO/JxDtcaWS0hHu/EP8DywGfJBfVfz6RufpvnFSA0p6+CZ0wpxOCrxLR2bKlex 2UmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=O5rWxrO4LKpgeKr94tt5HY0UsDhdyMRN5u3KCoWRxK4=; b=L+1vlkpGsTsgdxJOaMGcWPQ80fPNNtpZ38uu45A6ClN1Db3+HvjD/NKzLWbe0H0Rwn 6Y7MLutOoFT95GZG3eZSlePSLvCuVhCPrpCAowtnXm5rZt49yyFCMiXVIbAZ6poIQREB Oj0YrXmugDT6xw06ta+/i29piJz9u2+eglSiu0Nk1hIA/C0+Z1sVewTEbJ/m4k/WzVKH eIPa1Xq6pJknyDsTtbbDnIZhWyK5fiw56UHcLb4loWcKo3g0ybdYwMSabmNiycbkIm1K AgoWTgikA3fn4r1Z/7YzjgDfkckTo2OL2dwOGhAerOTj0IiGFQSRZeL2pduqfl+pHD2Q W7JQ== 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 u19si3873508pfk.128.2018.03.15.06.33.52; Thu, 15 Mar 2018 06:34:06 -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 S1751877AbeCONcF (ORCPT + 99 others); Thu, 15 Mar 2018 09:32:05 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:38866 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751459AbeCONcD (ORCPT ); Thu, 15 Mar 2018 09:32:03 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4C2B11529; Thu, 15 Mar 2018 06:32:03 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9E77D3F777; Thu, 15 Mar 2018 06:32:00 -0700 (PDT) Date: Thu, 15 Mar 2018 13:31:58 +0000 From: Mark Rutland To: Chintan Pandya Cc: catalin.marinas@arm.com, will.deacon@arm.com, arnd@arndb.de, ard.biesheuvel@linaro.org, marc.zyngier@arm.com, james.morse@arm.com, kristina.martsenko@arm.com, takahiro.akashi@linaro.org, gregkh@linuxfoundation.org, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, akpm@linux-foundation.org, toshi.kani@hpe.com Subject: Re: [PATCH v2 2/4] ioremap: Implement TLB_INV before huge mapping Message-ID: <20180315133157.ucbdg25jo5ew3t2h@lakrids.cambridge.arm.com> References: <1521117906-20107-1-git-send-email-cpandya@codeaurora.org> <1521117906-20107-3-git-send-email-cpandya@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1521117906-20107-3-git-send-email-cpandya@codeaurora.org> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 15, 2018 at 06:15:04PM +0530, Chintan Pandya wrote: > @@ -91,10 +93,15 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr, > > if (ioremap_pmd_enabled() && > ((next - addr) == PMD_SIZE) && > - IS_ALIGNED(phys_addr + addr, PMD_SIZE) && > - pmd_free_pte_page(pmd)) { > - if (pmd_set_huge(pmd, phys_addr + addr, prot)) > + IS_ALIGNED(phys_addr + addr, PMD_SIZE)) { > + old_pmd = *pmd; > + pmd_clear(pmd); > + flush_tlb_pgtable(&init_mm, addr); > + if (pmd_set_huge(pmd, phys_addr + addr, prot)) { > + pmd_free_pte_page(&old_pmd); > continue; > + } else > + set_pmd(pmd, old_pmd); > } > Can we have something like a pmd_can_set_huge() helper? Then we could avoid pointless modification and TLB invalidation work when pmd_set_huge() will fail. if (ioremap_pmd_enabled() && ((next - addr) == PMD_SIZE) && IS_ALIGNED(phys_addr + addr, PMD_SIZE) && pmd_can_set_huge(pmd, phys_addr + addr, prot)) { // clear entries, invalidate TLBs, and free tables ... continue; } Thanks, MArk.