Received: by 10.213.65.68 with SMTP id h4csp20781imn; Thu, 15 Mar 2018 08:22:22 -0700 (PDT) X-Google-Smtp-Source: AG47ELszOgLZDkuy6Gnn2dmITUbqr301vgupNgTItOCulmR+VQ/Z2A2UDRDAXo9b70Is8enBThST X-Received: by 2002:a17:902:b68c:: with SMTP id c12-v6mr4171572pls.52.1521127342833; Thu, 15 Mar 2018 08:22:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521127342; cv=none; d=google.com; s=arc-20160816; b=RtBcLZFseEdtv9WaSeSy4t1BqSw/TCRbzYzMUCoOyCmOu8oZPhqP+jIILTpbtIEqA2 Of+tFALtOItiThMpIrUfnsTYQo1PiXUjsxCLLVDg1hvk4ThKd+Z+rVV9V5s3hIpqgxYJ cpaydqTaXqSoz2jaqDoktP3WZxonkPt3+FlL/pr2iaywiDF4CcVT0M7c/0lKz1z5Vc7O 88DY+WDfgP+H8+YiHR3akb1X0jrtcyRVrEFKXvfp/DyXE96eIVnO54LbsQluuZWH2MBm W/VZSCN9Ti/eaTqFnWudkZzntq2ixBLwvRSsJ3Odu2G1QaryMeF0h6sn41GOx/EXpIh1 +3Tg== 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=FV0yKjozee9wCfSer6OIZi2DoukV7EIrrTPrD4SEdbA=; b=HeGB5POD593clE/WktEqXtrSGrx75FqSkk/7JIhmvhLnS8AfUWl0jPI1i1HsWHmifD IItDpeRsxHWRfn94OZXxFy1OTJulCRRFher9ULnHk92j83vz3H2KJR9hVmvjwD+0Bs+q SysHmBr3W+HBYWYkWeN1jiai8wQXO1Ra3sYtEdaKb4M85Ovu02u6vIZN+Oj4O3QIZ7fm PWwGDkwOuomoMCiPu52umQ9RPq0fOvDiiEbO/4aU5/+sJiQutWWktcQui/nG6vkkz7IQ LN9RyJALBnibBUe3ljxhz4M3EhdJkE93R7YfneDkKkgeJ4BnrcHzuBNL6E3xyCl7vXdm kabA== 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 h71si3531499pgc.717.2018.03.15.08.22.08; Thu, 15 Mar 2018 08:22:22 -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 S1752567AbeCOPUw (ORCPT + 99 others); Thu, 15 Mar 2018 11:20:52 -0400 Received: from foss.arm.com ([217.140.101.70]:41162 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751980AbeCOPUv (ORCPT ); Thu, 15 Mar 2018 11:20:51 -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 B93981435; Thu, 15 Mar 2018 08:20:50 -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 176543F487; Thu, 15 Mar 2018 08:20:47 -0700 (PDT) Date: Thu, 15 Mar 2018 15:20:45 +0000 From: Mark Rutland To: Chintan Pandya Cc: linux-arch@vger.kernel.org, toshi.kani@hpe.com, arnd@arndb.de, ard.biesheuvel@linaro.org, marc.zyngier@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, kristina.martsenko@arm.com, takahiro.akashi@linaro.org, james.morse@arm.com, gregkh@linuxfoundation.org, tglx@linutronix.de, akpm@linux-foundation.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 2/4] ioremap: Implement TLB_INV before huge mapping Message-ID: <20180315152045.uajoedfvdcynhus5@lakrids.cambridge.arm.com> References: <1521117906-20107-1-git-send-email-cpandya@codeaurora.org> <1521117906-20107-3-git-send-email-cpandya@codeaurora.org> <20180315133157.ucbdg25jo5ew3t2h@lakrids.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 07:49:01PM +0530, Chintan Pandya wrote: > On 3/15/2018 7:01 PM, Mark Rutland wrote: > > 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. > > Actually, pmd_set_huge() will never fail because, if > CONFIG_HAVE_ARCH_HUGE_VMAP is disabled, ioremap_pmd_enabled() > will fail and if enabled (i.e. ARM64 & x86), they don't fail > in their implementation. So, rather we can do the following. AFAICT, that's not true. The x86 pmd_set_huge() can fail under certain conditions: int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot) { u8 mtrr, uniform; mtrr = mtrr_type_lookup(addr, addr + PMD_SIZE, &uniform); if ((mtrr != MTRR_TYPE_INVALID) && (!uniform) && (mtrr != MTRR_TYPE_WRBACK)) { pr_warn_once("%s: Cannot satisfy [mem %#010llx-%#010llx] with a huge-page mapping due to MTRR override.\n", __func__, addr, addr + PMD_SIZE); return 0; } prot = pgprot_4k_2_large(prot); set_pte((pte_t *)pmd, pfn_pte( (u64)addr >> PAGE_SHIFT, __pgprot(pgprot_val(prot) | _PAGE_PSE))); return 1; } ... perhaps that can never happen in this particular case, but that's not clear to me. Thanks, Mark.