mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86/microcode: move microcode_mutex declaration
@ 2023-05-22  6:27 Christian Gmeiner
  2023-05-26  0:34 ` Ashok Raj
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Gmeiner @ 2023-05-22  6:27 UTC (permalink / raw)
  To: Borislav Petkov, Thomas Gleixner, Ingo Molnar, Dave Hansen, x86,
	H. Peter Anvin
  Cc: Christian Gmeiner, linux-kernel

The microcode_mutex is only used when CONFIG_MICROCODE_LATE_LOADING
is enabled. Move it into the ifdef block.

Fixes a compiler unused-variable warning seen on gcc.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
---
 arch/x86/kernel/cpu/microcode/core.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index 3afcf3de0dd4..4f6ebadba2fb 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 {
@@ -323,6 +309,20 @@ void reload_early_microcode(unsigned int cpu)
 static struct platform_device	*microcode_pdev;
 
 #ifdef CONFIG_MICROCODE_LATE_LOADING
+/*
+ * 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);
+
 /*
  * Late loading dance. Why the heavy-handed stomp_machine effort?
  *
-- 
2.40.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] x86/microcode: move microcode_mutex declaration
  2023-05-22  6:27 [PATCH] x86/microcode: move microcode_mutex declaration Christian Gmeiner
@ 2023-05-26  0:34 ` Ashok Raj
  0 siblings, 0 replies; 2+ messages in thread
From: Ashok Raj @ 2023-05-26  0:34 UTC (permalink / raw)
  To: Christian Gmeiner
  Cc: Borislav Petkov, Thomas Gleixner, Ingo Molnar, Dave Hansen, x86,
	H. Peter Anvin, linux-kernel, Ashok Raj

On Mon, May 22, 2023 at 08:27:12AM +0200, Christian Gmeiner wrote:
> The microcode_mutex is only used when CONFIG_MICROCODE_LATE_LOADING
> is enabled. Move it into the ifdef block.
> 
> Fixes a compiler unused-variable warning seen on gcc.
> 
> Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>

Thanks Christian

I tried to compile with W=1 but not sure why I'm not getting that error
when CONFIG_MICROCODE_LATE_LOADING=n

I'm using GCC 12.2.0 on a ubuntu system.

But  your change seems fine.


> ---
>  arch/x86/kernel/cpu/microcode/core.c | 28 ++++++++++++++--------------
>  1 file changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
> index 3afcf3de0dd4..4f6ebadba2fb 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 {
> @@ -323,6 +309,20 @@ void reload_early_microcode(unsigned int cpu)
>  static struct platform_device	*microcode_pdev;
>  
>  #ifdef CONFIG_MICROCODE_LATE_LOADING
> +/*
> + * 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);
> +
>  /*
>   * Late loading dance. Why the heavy-handed stomp_machine effort?
>   *
> -- 
> 2.40.1
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-26  0:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-22  6:27 [PATCH] x86/microcode: move microcode_mutex declaration Christian Gmeiner
2023-05-26  0:34 ` Ashok Raj

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®