From patchwork Fri Aug 4 07:58:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 131039 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:44a:b0:3f2:4152:657d with SMTP id ez10csp134273vqb; Fri, 4 Aug 2023 02:23:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGsCIeawCnUZnbAYXuFS7aBcylXktEHxeFDKaQyg38goby7vAyycMdT9TAuyBIqMRpfb3xh X-Received: by 2002:aa7:de06:0:b0:523:983:9917 with SMTP id h6-20020aa7de06000000b0052309839917mr1131095edv.1.1691141025604; Fri, 04 Aug 2023 02:23:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691141025; cv=none; d=google.com; s=arc-20160816; b=XHqWWULbogo8Msl2Vf8drP6kLTUky6lD50P62Navyvn6tCVmVxc3EoKDUQL+5DO+3y S1YBVNstPF3ibcpQPeIxZ+fvaGGZGQRUSBGFnUpN1FFsO4vOkc8ZgxPHdK3te6kaO+1S vMi7uVGKH2vdCQZXoMKzgCGwI3LRUiiO7P0kfRPc5OVowYGa06phxiclXYG2nRbZ6fYD 9Z5hZdfMXmzWoMQ70eg6qELWE+/sAlseGaiNqseyGUO24SqeOAZGXJm6zFxmh80HOyXO GJDwu8ioGosSA4CHxjBb2NITvLUyO2BcWLFmuTh7HvvIwJlnFhNEea7DHi/UmI74RPPu OviQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:dkim-signature:dkim-signature:date; bh=c6FKEDuzMKNNLeZG2jeuUZN+W0ab8lNF9LA6bdXeiC8=; fh=6Z9dqcB2WpAtFRMl3B1xHjzTEAjPrB3tQe6Ua+V3BSo=; b=PfJG3S6dCBbRs4SuT9j9tAESUWnt+SBFo1/frhBRovk6+e9PPxQMK63Fy0FBO4rmVz ng+AFXD7okLyFkU/bq1etF4INqbEgmClPBbJnSiOWLTnQzdh7+wDZVl/nlp3iwR/uOjt vzA3jR+m9c9UUgMoEcR67hkK8FvsyUs/O/Qg1tY1KmGCUhn9Y6hKjPYQK8OQyd9Lotdf eF+JiM0WKQRkL/BleFrDkXXyt/maEVP0wAEX6aYOaaGKqwIa0iUEjL7g7rfg62z42NYi s7akqWchTobM/xD1muXXRWgssOPxsMMpy0XCqh6yKMQQiuL8MPmBt+iDNyqUzvVD3Dw3 LPCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=TTaIxnY+; dkim=neutral (no key) header.i=@linutronix.de header.b=+LYWqR9T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r22-20020aa7cfd6000000b005221dab0137si1296051edy.612.2023.08.04.02.23.21; Fri, 04 Aug 2023 02:23:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=TTaIxnY+; dkim=neutral (no key) header.i=@linutronix.de header.b=+LYWqR9T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234279AbjHDH67 (ORCPT + 99 others); Fri, 4 Aug 2023 03:58:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232676AbjHDH65 (ORCPT ); Fri, 4 Aug 2023 03:58:57 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B73D1702 for ; Fri, 4 Aug 2023 00:58:56 -0700 (PDT) Date: Fri, 4 Aug 2023 09:58:53 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1691135934; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c6FKEDuzMKNNLeZG2jeuUZN+W0ab8lNF9LA6bdXeiC8=; b=TTaIxnY+P1/OgI3xSNhMJQqXKdtkCIpjiPmGRBvtIBkuE3gcqdrZKvrDEh17IODdfGx+Qg WIyo0QwtyOfFsSZYrQlcVKDnwGtsmt8uYQMz5fGSXB8ZAY/mRRrNmtJFVpkaPIpfTC+OIk wXdEZUKzTb/zsCAIzEaxjMd+NHq8AIi//mQM+/Ltbk6COGVOz3KMlPi/CME8dHyUh/2pzx 1Ogg6nxHoRWoYUSF551Scmy4eOHXFKbn+5AZV15aGd9tOEGpRClutO7fZt9hb5gO9b4zi+ z8V6nehdwS0Da4xkervOfpTwU3/JrUNti5CJnDnWTwt2Sg97jhVRepBDFRBSpw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1691135934; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c6FKEDuzMKNNLeZG2jeuUZN+W0ab8lNF9LA6bdXeiC8=; b=+LYWqR9TRuZsy6j42SuBFKiTnxdywdtKQzM2ELnLZpEgH23jtWWQl4PWyr98g69a7vd3x5 2kv1fwf1s1V6/dBQ== From: Sebastian Andrzej Siewior To: Sohil Mehta Cc: linux-kernel@vger.kernel.org, x86@kernel.org, "H. Peter Anvin" , Borislav Petkov , Dave Hansen , Ingo Molnar , Thomas Gleixner Subject: [PATCH v2] x86/microcode: Remove microcode_mutex. Message-ID: <20230804075853.JF_n6GXC@linutronix.de> References: <20230803083253.VGMnC9Gd@linutronix.de> <7f31f938-cd4f-bb1b-d44d-57adabf62c51@intel.com> <20230804075504.MxYvbNle@linutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230804075504.MxYvbNle@linutronix.de> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773206101934393149 X-GMAIL-MSGID: 1773289892011989702 microcode_mutex is only used by reload_store(). It has a comment saying "to synchronize with each other". Other user of this mutex have been removed in the commits 181b6f40e9ea8 ("x86/microcode: Rip out the OLD_INTERFACE"). b6f86689d5b74 ("x86/microcode: Rip out the subsys interface gunk") The sysfs interface does not need additional synchronisation vs itself because it is provided as kernfs_ops::mutex which is acquired in kernfs_fop_write_iter(). Remove superfluous microcode_mutex. Link: https://lore.kernel.org/r/20230803083253.VGMnC9Gd@linutronix.de Signed-off-by: Sebastian Andrzej Siewior Reviewed-by: Sohil Mehta --- v1…v2: - Add another commit to the commit description which removed another user. Suggested by Sohil Mehta. - Also update the comment in microcode_check(). Suggested by Sohil Mehta. arch/x86/kernel/cpu/common.c | 3 +-- arch/x86/kernel/cpu/microcode/core.c | 6 ------ 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 0ba1067f4e5f1..de49b9cd8077a 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -2276,8 +2276,7 @@ void store_cpu_caps(struct cpuinfo_x86 *curr_info) * @prev_info: CPU capabilities stored before an update. * * The microcode loader calls this upon late microcode load to recheck features, - * only when microcode has been updated. Caller holds microcode_mutex and CPU - * hotplug lock. + * only when microcode has been updated. Caller holds and CPU hotplug lock. * * Return: None */ diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 3afcf3de0dd49..2f9d35744bc41 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -54,15 +54,12 @@ LIST_HEAD(microcode_cache); * * All non cpu-hotplug-callback call sites use: * - * - microcode_mutex to synchronize with each other; * - cpus_read_lock/unlock() to synchronize with * the cpu-hotplug-callback call sites. * * We guarantee that only a single cpu is being * updated at any particular moment of time. */ -static DEFINE_MUTEX(microcode_mutex); - struct ucode_cpu_info ucode_cpu_info[NR_CPUS]; struct cpu_info_ctx { @@ -488,10 +485,7 @@ static ssize_t reload_store(struct device *dev, if (tmp_ret != UCODE_NEW) goto put; - mutex_lock(µcode_mutex); ret = microcode_reload_late(); - mutex_unlock(µcode_mutex); - put: cpus_read_unlock();