From patchwork Thu Jun 20 13:06:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 167330 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2048887ilk; Thu, 20 Jun 2019 06:06:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqx4zlS5z58snYdaeh+4bHqRVoPLUux260KycQmMtLr5ocpDU8G7RrXlru7wkdTxzA9NWhV3 X-Received: by 2002:a62:e301:: with SMTP id g1mr32486004pfh.119.1561036003638; Thu, 20 Jun 2019 06:06:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561036003; cv=none; d=google.com; s=arc-20160816; b=SSjqa3gy/DHIF/ZYC5c7mlRJ//6st8Q8+KP3zLUu41yhgPGl8/kKdcDRBJdbmLUbUA nII70O6z6Hv2c7yLuwiHKzhcFWS/uGEC/QAqsWgGKRcvJjKuWR98e5xLkU5pUkX0+KHt 4tVL9/5wN7giqi6KrnOtzUgpo1EGGOWo7rBEFmB9sVoAZ02KCc/m7zNXYsE1dMjeRN06 oJcH7+R75PMZ5wWyX7Zj4GWm1PqaS6gxY4mO5b1WxhMP75T49YtItp5h1sF6tGbzs6lL jpme+UlKdoTMfaYthwgmuCPXC0Z4rLte6LSWyXlZl9SiKfwc01NEiYTXzuQNeKbWQwmp etyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=P19iB0RN+QVwJmlK/R/hy8q7m6sILENbHxPhaxnl15c=; b=Tk/dJZiAbLAZdHRuIiTGS+YItCTOPidSaDaP0EcDHM7m9NTNXuoBXKOIU4kweTrkQY IAolO2ZOGt+Fn01N2cpGf5xwlMxaC3VxvhNOKdkEEDfmLZcFskxPnvDOrZITMspEnn7W jHB8Bi33fMG4v027H5Q+9+uPW0cJBGOGVi0QBF0M979G7qWnOmVHe5mxiaRXcDrwuCQr QtpDhQivoZZUmlchCD+mX94Fhcciohda6xYEjkn+LGppO5cY7XIMphT+YEWOG8SxgHJh J7SKB7Ghy04luqPUUIspPrbkrmrN4nxO38ZA51g8+M8vLK9qpO0ME9VQ0SnX5ChkYkuG BIcQ== 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 k4si5435948pgq.293.2019.06.20.06.06.42; Thu, 20 Jun 2019 06:06:43 -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 S1732044AbfFTNGl (ORCPT + 30 others); Thu, 20 Jun 2019 09:06:41 -0400 Received: from foss.arm.com ([217.140.110.172]:36808 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732029AbfFTNGi (ORCPT ); Thu, 20 Jun 2019 09:06:38 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8B5CB360; Thu, 20 Jun 2019 06:06:38 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3704F3F718; Thu, 20 Jun 2019 06:06:37 -0700 (PDT) From: Julien Grall To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu Cc: james.morse@arm.com, marc.zyngier@arm.com, julien.thierry@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, Julien Grall Subject: [RFC v2 10/14] arm64/mm: Introduce a callback to flush the local context Date: Thu, 20 Jun 2019 14:06:04 +0100 Message-Id: <20190620130608.17230-11-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190620130608.17230-1-julien.grall@arm.com> References: <20190620130608.17230-1-julien.grall@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Flushing the local context will vary depending on the actual user of the ASID allocator. Introduce a new callback to flush the local context and move the call to flush local TLB in it. Signed-off-by: Julien Grall --- arch/arm64/mm/context.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) -- 2.11.0 diff --git a/arch/arm64/mm/context.c b/arch/arm64/mm/context.c index fbef5a5c5624..3df63a28856c 100644 --- a/arch/arm64/mm/context.c +++ b/arch/arm64/mm/context.c @@ -39,6 +39,8 @@ static struct asid_info cpumask_t flush_pending; /* Number of ASID allocated by context (shift value) */ unsigned int ctxt_shift; + /* Callback to locally flush the context. */ + void (*flush_cpu_ctxt_cb)(void); } asid_info; #define active_asid(info, cpu) *per_cpu_ptr((info)->active, cpu) @@ -266,7 +268,7 @@ static void asid_new_context(struct asid_info *info, atomic64_t *pasid, } if (cpumask_test_and_clear_cpu(cpu, &info->flush_pending)) - local_flush_tlb_all(); + info->flush_cpu_ctxt_cb(); atomic64_set(&active_asid(info, cpu), asid); raw_spin_unlock_irqrestore(&info->lock, flags); @@ -298,6 +300,11 @@ asmlinkage void post_ttbr_update_workaround(void) CONFIG_CAVIUM_ERRATUM_27456)); } +static void asid_flush_cpu_ctxt(void) +{ + local_flush_tlb_all(); +} + /* * Initialize the ASID allocator * @@ -308,10 +315,12 @@ asmlinkage void post_ttbr_update_workaround(void) * 2. */ static int asid_allocator_init(struct asid_info *info, - u32 bits, unsigned int asid_per_ctxt) + u32 bits, unsigned int asid_per_ctxt, + void (*flush_cpu_ctxt_cb)(void)) { info->bits = bits; info->ctxt_shift = ilog2(asid_per_ctxt); + info->flush_cpu_ctxt_cb = flush_cpu_ctxt_cb; /* * Expect allocation after rollover to fail if we don't have at least * one more ASID than CPUs. ASID #0 is always reserved. @@ -332,7 +341,8 @@ static int asids_init(void) { u32 bits = get_cpu_asid_bits(); - if (!asid_allocator_init(&asid_info, bits, ASID_PER_CONTEXT)) + if (!asid_allocator_init(&asid_info, bits, ASID_PER_CONTEXT, + asid_flush_cpu_ctxt)) panic("Unable to initialize ASID allocator for %lu ASIDs\n", 1UL << bits);