Received: by 10.213.65.68 with SMTP id h4csp1705311imn; Thu, 15 Mar 2018 07:20:38 -0700 (PDT) X-Google-Smtp-Source: AG47ELs2M3D29B8nZPDVDmXt3NDj5im8HXCPWIi5CUBVKU8Q7hIKeur5uGdfHssbb83+BD7aaJCh X-Received: by 10.98.211.198 with SMTP id z67mr8004026pfk.0.1521123638029; Thu, 15 Mar 2018 07:20:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521123637; cv=none; d=google.com; s=arc-20160816; b=cJGtNVEQ26cKRLoVikkCZHenl2gbC69FjVv4G9Y4p8FJLk8qZe/6s2jKsTRr9+XLjv AUbjPvKwQhM0/lJhkBJz7JKhGxmllHXMeCwK8ELDG5kYMjcpn5svg9RbDuX3Go6Ps7qb sVNTiosnYOfGYijJPI8q5khgkpPWKKj5mQ7z8F7Up0LfK/BpX8tLpYjVe5KYg1sAdao1 wg+H3NytgRp6RC18RIZpzRvd/3r9e2cioNpP1i0oIpP10CKlz3lhNsd/n5O4vIhBRIRD eY9BxOBlxZsYJ+5ZwY1WbM6Wxu40YyJtF2Ek2lvIo47Hpe+hVO34Yx4BAv6SPXUgfnlb 61eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=lTdWX7dJi6KG/Huqs2tjXvi/GzCd1mY2krS1Qcz9F0E=; b=IETmxCa97rW7GPnAGTuypdezM2a/4Um1G+Kzx8Pn2546hW0rAGcJCPzub+efKiRa4d rDZQ7ap5DoZqwE4MyrB+nsefxSXujCnC5teyAfumb5lmYD4ZY10sBc3R8OqDeHOHdaKS ushEbCVmwA2yM51UU4z48CPddqFia3zafkAZ7xhwtY30ZNMDTKAqIPnrCnhOxT8ue2yj eGAWF7wfRZFDdz37H9YKF9HEjneqcn6GRiN9AXbYD9/51jKgPPtixBWAVSS2d8S7X3ug GRlOORS4ehYRndS/UaCBdXomH21yX7Ju+qc/FUeYrKUDtApTztran66lUwuzUlYc3t3w Mevg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=dgUY7mmG; dkim=pass header.i=@codeaurora.org header.s=default header.b=Df6B9ruY; 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 u82si3905515pfg.389.2018.03.15.07.20.23; Thu, 15 Mar 2018 07:20:37 -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; dkim=pass header.i=@codeaurora.org header.s=default header.b=dgUY7mmG; dkim=pass header.i=@codeaurora.org header.s=default header.b=Df6B9ruY; 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 S932122AbeCOOTL (ORCPT + 99 others); Thu, 15 Mar 2018 10:19:11 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:44378 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751909AbeCOOTK (ORCPT ); Thu, 15 Mar 2018 10:19:10 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 691E660452; Thu, 15 Mar 2018 14:19:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521123549; bh=dKqv5yjBy45h2i4TNRd/d6KkaMaU2UAR7RRTv4vlD9U=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=dgUY7mmGfBnzZucjFbWN/ro3i38JmHfB3PmAVsuscbAKnCkq3/2IXPQmFeCUvBpJy oDEvGrfW50e7jJWkzsnpGWBhPFxqoxQD7Xt+PimlC+11DXtO5zthurj+1swTatf37L yn4+F5hmgToZwvPhLDBH0ImLGsH75g3nw3Y+l+xM= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from [10.204.79.109] (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: cpandya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7F41560452; Thu, 15 Mar 2018 14:19:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521123547; bh=dKqv5yjBy45h2i4TNRd/d6KkaMaU2UAR7RRTv4vlD9U=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=Df6B9ruYd5vCAj4ny1ksoa3MCU8jljroON4mY9wq2kHF/S71uLt/MMDPgGMYV23zy KbfiVb8Pas/iHHOfKNkuyxpy6ddsSgsMs45xvqWhGUU5KFytPfpFVcaWqhUJYhfmgZ DP/evXC77Kv/mN5bA9nqB0830hFQQZoyeXNBjO6c= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7F41560452 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=cpandya@codeaurora.org Subject: Re: [PATCH v2 2/4] ioremap: Implement TLB_INV before huge mapping To: Mark Rutland 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 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> From: Chintan Pandya Message-ID: Date: Thu, 15 Mar 2018 19:49:01 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180315133157.ucbdg25jo5ew3t2h@lakrids.cambridge.arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. - if (pmd_set_huge(pmd, phys_addr + addr, prot)) { - pmd_free_pte_page(&old_pmd); - continue; - } else - set_pmd(pmd, old_pmd); + pmd_set_huge(pmd, phys_addr + addr, prot) + pmd_free_pte_page(&old_pmd); + continue; > > 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. > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel > Chintan -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project