From patchwork Fri Mar 24 11:47:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 74502 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp575860vqo; Fri, 24 Mar 2023 05:12:24 -0700 (PDT) X-Google-Smtp-Source: AKy350b7q5je6lFig+C3lBv3wT1IHCMDt3wec/lj5+NYwaLaXZ4zp9FI861GfhFAypZHdpGMYoAG X-Received: by 2002:a17:906:4a4e:b0:889:1eb1:7517 with SMTP id a14-20020a1709064a4e00b008891eb17517mr2679980ejv.30.1679659944373; Fri, 24 Mar 2023 05:12:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679659944; cv=none; d=google.com; s=arc-20160816; b=afH4b8dYpEokJhciICRMcVlv2H01c0yVjQ3L8WfgImI04xFDClZiWvUMuSVWm9nHlW g0qCukyg5dOePxksEtEjqu0cDeeMJCBX5O0lHE+6z+cS4HSvPMNNBmwgrs31J+ffWSBP IvWplVTrISXWAN29ejtCk/Lb3/SE0Nqc9tcc6a811m2oVn7buT14NAY3nmtDlayhpQzV MxLOFNG/+Ilt5lFHYVvSccU/nCa2S50NyGlEYJ0XvV2XJgh9xvmUzSWUUDpSd6uYf44q VbnXi/3v8wvaoMtIvDNIUZRAneLs3Vb+XRJZ1UFWMyKHIUAc6s9eDDhAAhzcVJ0Uib9g qs/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:dkim-signature:dkim-signature:from; bh=KDPHyC6kWyePMtKLTpdAD+GT0kcy5lpaGKk40vT9Trk=; b=RwfQ8hLrXZd6UJnUKcZx+ZmfTEq7CiitI+VbGgseZrC0is8H4jKMOeVa5Goh5yr909 KZprDpM1r7cbfGhTwxDII0Mg44/ZHnvE23IKgla5wF2jG4A7BMqDILtNPIOkESd9J4/8 Q+/YDhGXt+sCJz58sSphH2fl7ki9iC8+0MoZnNir9Rai+L+tca7ITWXDlQ60IkqHSjO8 adqgEJzxbMWRZgE3EzBWNEPL22iCVCQ0zsdqGbx2Aj0v41Qv8K+m0SNUZ/uoUPeBbxJO Yfg5tnP/Ymyz3qe50gqO+RGNWge/kEcdBZV8crVmeBue72bGFyiSQSIgAfbBq7h0P7tM XenQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pYBaWSXT; dkim=neutral (no key) header.i=@linutronix.de header.b=p7MsW3zN; 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 ne12-20020a1709077b8c00b0093b38ae1025si7604624ejc.584.2023.03.24.05.12.00; Fri, 24 Mar 2023 05:12:24 -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=pYBaWSXT; dkim=neutral (no key) header.i=@linutronix.de header.b=p7MsW3zN; 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 S231402AbjCXLr0 (ORCPT + 99 others); Fri, 24 Mar 2023 07:47:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229600AbjCXLrY (ORCPT ); Fri, 24 Mar 2023 07:47:24 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54D17212B1 for ; Fri, 24 Mar 2023 04:47:23 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1679658441; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=KDPHyC6kWyePMtKLTpdAD+GT0kcy5lpaGKk40vT9Trk=; b=pYBaWSXTO+Wz8eDa1FUSKeX9XRTcRQiGR+tn0DaBZaj2pSQTCpNciw284AfXoUL43F9/pV ZOLFU7nwE/quHO0F/ujK2j9/zEHeD3HdpaL210Mc/1M7FdJZ3el8yttzJ7i5vac/ID3MFm wySJqyLXZNpqqqLQjb/IU/8eqp1/CndsZSgnYrYSbhZJ746MDVQ8yJRQpvfi1jPB/zpVOM YgnnRtaecElUEyVKkHOnWdGISCEUpK/RlIbSKRs79znEqHpzkOzefb9JTMgZ5b1AIwe0C7 6UOiqpAsvC0RbYOX2EZ7f/wtsT0JpFP5DGnM4zBa/Z9NqH2V2VUsw+l+0fMFBQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1679658441; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=KDPHyC6kWyePMtKLTpdAD+GT0kcy5lpaGKk40vT9Trk=; b=p7MsW3zN+G0mjBxUNC5rQL58AdcZjYToNkx+sxTQB3HC9GmzxCrXtkkXG+pbPo6AYvg4le wr4fyU/kQ4RsauCw== To: Borislav Petkov Cc: linux-kernel@vger.kernel.org Subject: [PATCH] x86/microcode: move @microcode_mutex definition near usage Date: Fri, 24 Mar 2023 11:47:20 +0000 Message-Id: <20230324114720.1756466-1-john.ogness@linutronix.de> MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761251010782637399?= X-GMAIL-MSGID: =?utf-8?q?1761251105492967670?= If CONFIG_MICROCODE_LATE_LOADING is not enabled, the compiler warns: 'microcode_mutex' defined but not used Since reload_store() is the only function using this mutex, move the mutex definititon there. Then it is also within the #ifdef block for CONFIG_MICROCODE_LATE_LOADING. Signed-off-by: John Ogness --- arch/x86/kernel/cpu/microcode/core.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) base-commit: 1e760fa3596e8c7f08412712c168288b79670d78 diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 7a329e561354..e7b8f7ad105d 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -49,20 +49,6 @@ bool initrd_gone; LIST_HEAD(microcode_cache); -/* - * Synchronization. - * - * 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 { @@ -465,6 +451,20 @@ static int microcode_reload_late(void) return ret; } +/* + * Synchronization. + * + * 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); + static ssize_t reload_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)