From patchwork Thu Feb 29 23:21:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13577713 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0FA84C54E49 for ; Thu, 29 Feb 2024 23:22:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C80FF6B009F; Thu, 29 Feb 2024 18:22:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C06606B00A1; Thu, 29 Feb 2024 18:22:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A80CF6B00A3; Thu, 29 Feb 2024 18:22:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 945776B009F for ; Thu, 29 Feb 2024 18:22:24 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 71EA4A1606 for ; Thu, 29 Feb 2024 23:22:24 +0000 (UTC) X-FDA: 81846417408.10.AD8012B Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf13.hostedemail.com (Postfix) with ESMTP id BDA8C2001B for ; Thu, 29 Feb 2024 23:22:22 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=sifive.com header.s=google header.b="Rc/zXJzV"; spf=pass (imf13.hostedemail.com: domain of samuel.holland@sifive.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=samuel.holland@sifive.com; dmarc=pass (policy=reject) header.from=sifive.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709248942; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wHMbuRyYmPRZ8L34XsarFB0wBhmLHt6PApeEi+FQBPY=; b=RwMBvBVd7/l3PSJghCByimwURjYBieImiyKvqJBGdrHHMKwGrLscy673GOKZfS5GA5jf/J 6M3y8w90WWAMgJW4qOoUANMdndwiuWtiFS7ZlECwciBJS5WLruXUxuzVC4LAzgLW53WAoL gpfh6iivbXo1v1AZBPBoyE4WXahctTQ= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=sifive.com header.s=google header.b="Rc/zXJzV"; spf=pass (imf13.hostedemail.com: domain of samuel.holland@sifive.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=samuel.holland@sifive.com; dmarc=pass (policy=reject) header.from=sifive.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709248942; a=rsa-sha256; cv=none; b=SomuLuU97ZKRbesK8N9V7vvQ25IqJNjDfbYkRku/SEuJZKU5m9ZZKccwZO6vHB5aGAeRm1 ZWwxuZqAj+UvcA9yTfwLQ/ZQLC+8bueChhD/vU9n3XgdN/B0ncAYybaxjVEnMwhsMbmaiX eKPXCnTCeEwfhJEM9Iafvn02OzCpya8= Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6e58d259601so911849b3a.3 for ; Thu, 29 Feb 2024 15:22:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1709248942; x=1709853742; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wHMbuRyYmPRZ8L34XsarFB0wBhmLHt6PApeEi+FQBPY=; b=Rc/zXJzV8IHMtkYdMBdQaV4Oxngj23Qc6IBKHJIUdiJIYcgaKlBylVIaYboiovtY1c 1b+La/9TyLhkl4qEBx7PjUC4O/N2beooeCw2IGMKvQJCJc7jlchWKHpXePp7Y5917OSA FgXZ6/tj+acV4eNUVvlR7Njy9zDPxFeBMwKSEqYWaTjrzRH92rTipkz5daGF8u+qSdAA d+xREctrwA2RV6pJTtfrgvRMKWRRjWXO1ioDqDig1CdWYcdqgp5mIAQAdysH2tSBPzcy 2z8WRyPIh99ia3V+VQZ2E4T2BsI435WcThKvmhIx7BWijdS62xnYCq+jY624ag6Pjy05 rBaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709248942; x=1709853742; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wHMbuRyYmPRZ8L34XsarFB0wBhmLHt6PApeEi+FQBPY=; b=di258RWcH1V48Mu0iuam5bOhw5AcxaE9mc2+ogbVINpbkufI754WUeUfqAGQ/z/uwI jo2TKRVL/KBiHG29nhrUj+cSc0pSWGhbkiM8glks9lBwBC8OGNwjWkp/GDuNAD024NV5 wbAhjFm2zgwgCOilgjL9mxgTkheWJBN14UmtasC2nlyFsPUJ0Sg+jyhQrDQCtZ+50/B0 ejYt0DF0P4X9CqYYLLqNnkxhuyHqIlVpH7QMtppBReVe+ECpC62gJXdFrOWnSySSvwVU gw666n0D2JhzBAXTR/udlyC2jzfZHfzQRByqlN/wRzCH9Ncl2x2tGNVRDJ70AXFOZbuK 6oZw== X-Forwarded-Encrypted: i=1; AJvYcCVyFlMnsumlkF29d3G7VUsZQ80x7WwhbZI06zofwwmnYvhntuTTeF5CO+Elx2dO/0o35zJHKllFckC67PXvUoLzLQI= X-Gm-Message-State: AOJu0YzwPUMTTpINoiqNbERL8yS1xDdclqxIod0Ghcb3H8WKS2zy7eXy wEZYdGIE+xiUSLcbysWUQToPYcbUIMdlcPlfnvFyNXFJk0gSKZgeqM1Hq7ukeEE= X-Google-Smtp-Source: AGHT+IE0KT3RuIOZoiwK4WAulPfaiFPRjhF12PREr/S+YlSI1LgFKc32EbVKWDUbhqJfm1349m8bOA== X-Received: by 2002:a05:6a00:1955:b0:6e4:eb29:357 with SMTP id s21-20020a056a00195500b006e4eb290357mr165166pfk.12.1709248941678; Thu, 29 Feb 2024 15:22:21 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id c6-20020aa78806000000b006e55aa75d6csm1779719pfo.122.2024.02.29.15.22.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 15:22:21 -0800 (PST) From: Samuel Holland To: Palmer Dabbelt , linux-riscv@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexandre Ghiti , Jisheng Zhang , Yunhui Cui , Samuel Holland Subject: [PATCH v5 08/13] riscv: Avoid TLB flush loops when affected by SiFive CIP-1200 Date: Thu, 29 Feb 2024 15:21:49 -0800 Message-ID: <20240229232211.161961-9-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240229232211.161961-1-samuel.holland@sifive.com> References: <20240229232211.161961-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: BDA8C2001B X-Rspam-User: X-Stat-Signature: ar5c3d5edjnz9i1qqx53e3o5zqiypkfe X-Rspamd-Server: rspam01 X-HE-Tag: 1709248942-783585 X-HE-Meta: U2FsdGVkX18ELhFmfQls39lL9betIBAPR3koQzPrMJ+h6ZtGule4G61+mebWe9Cs9swpsNNztQgx9nI8P3XxOKonro+UBoU/weJQXjeBR5T2gZ3IIorNv7oPoiSDO8zdARl99geCxOzRzYTe02SpxuzXCKgLkaAdGdemQ2lcDAnmwXVm0fW+zpUIq9YsWwIwYqGzl+bHAxS2h4ncRQAT1lEjcsZd6nZcECWDwJyQ8HeAuAyaYPyECKjb4iPtu4wQuuEZmiEE74u+OEf6HHtKzn6nvFFDzuY0GDAr8IU4lVVnDqnY3FZz2nWkIS57qGw8AuwsSTeO60dZh4s6nt7OCnFsQAs9a+xkmfzXL8Njl3yhHjkeJ+Ga63dehRo2dIGXW991kUeFqd4tR+WVau8LaN/lYlqqnnra8G2IKyn++mHwg1VutKoDgNLnHDyCSTUIuRqgRa3qCza6mv4fHjzlQ+yyH2DcfOBYgKuEsU73cZkyqKuRouuJZsmZ7ScW7o2Q44fDssq+maxem7IbnTdLofkRxs/eFpdWCH1ZhwFZEAB5oITQgfjdj1NFzv3bmHFNLybIe7HDuNwOMdEnJYmamnFTzdNmrGxTiNpKvAJZrqspJYzyExZvBvoQyrkiblow44D+hud9bIrZlBtVetBBcOXXIpv+jiKRSJ9EYlMyqRW/GZ8DLQz65mSq3LKquUNJUcEUJkyUYAWEZt8Fe7yogIJfLr9qB6XTNn6y8Efv1aI+UYPzaP+OmOfwLo+RvI8RJJT4NFi4AOVMuUzUn9D1kghO5MiubGgl0HSaadQLZFk89JtJWHEICbzJlUJKbyLtxIcFDQvqjWUEqml0F0KpJj4wDuBPwH0f48tFRdi2yNR4kf5Vk0LuhWTjqr4vqnVDKTpMUbfKKw1Z3qxnA8w9r5AgfzsC0573bzk0oTo4exot3XWHozIQ3mLtyxh0h8yWsNpCW8pBiJ9Opneousk FwpDpm7E LhgnFVqvxulCcVdzY924JJDqx5r9CdRswHrbqvrxLJ4ruAjMZ537GdngOMe1JUuaMp597iZ11xhFn7FURwlx7s+ReukCjcS0A6YcraPQP42yqMn8I4yH1C7riFA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000052, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Since implementations affected by SiFive errata CIP-1200 always use the global variant of the sfence.vma instruction, they only need to execute the instruction once. The range-based loop only hurts performance. Signed-off-by: Samuel Holland --- (no changes since v4) Changes in v4: - Only set tlb_flush_all_threshold when CONFIG_MMU=y. Changes in v3: - New patch for v3 arch/riscv/errata/sifive/errata.c | 5 +++++ arch/riscv/include/asm/tlbflush.h | 2 ++ arch/riscv/mm/tlbflush.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/riscv/errata/sifive/errata.c b/arch/riscv/errata/sifive/errata.c index 3d9a32d791f7..716cfedad3a2 100644 --- a/arch/riscv/errata/sifive/errata.c +++ b/arch/riscv/errata/sifive/errata.c @@ -42,6 +42,11 @@ static bool errata_cip_1200_check_func(unsigned long arch_id, unsigned long imp return false; if ((impid & 0xffffff) > 0x200630 || impid == 0x1200626) return false; + +#ifdef CONFIG_MMU + tlb_flush_all_threshold = 0; +#endif + return true; } diff --git a/arch/riscv/include/asm/tlbflush.h b/arch/riscv/include/asm/tlbflush.h index 463b615d7728..8e329721375b 100644 --- a/arch/riscv/include/asm/tlbflush.h +++ b/arch/riscv/include/asm/tlbflush.h @@ -66,6 +66,8 @@ void arch_tlbbatch_add_pending(struct arch_tlbflush_unmap_batch *batch, unsigned long uaddr); void arch_flush_tlb_batched_pending(struct mm_struct *mm); void arch_tlbbatch_flush(struct arch_tlbflush_unmap_batch *batch); + +extern unsigned long tlb_flush_all_threshold; #else /* CONFIG_MMU */ #define local_flush_tlb_all() do { } while (0) #endif /* CONFIG_MMU */ diff --git a/arch/riscv/mm/tlbflush.c b/arch/riscv/mm/tlbflush.c index 365e0a0e4725..22870f213188 100644 --- a/arch/riscv/mm/tlbflush.c +++ b/arch/riscv/mm/tlbflush.c @@ -11,7 +11,7 @@ * Flush entire TLB if number of entries to be flushed is greater * than the threshold below. */ -static unsigned long tlb_flush_all_threshold __read_mostly = 64; +unsigned long tlb_flush_all_threshold __read_mostly = 64; static void local_flush_tlb_range_threshold_asid(unsigned long start, unsigned long size,