x86 ucode: optimizing microcode update
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 22 Jan 2009 11:11:39 +0000 (11:11 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 22 Jan 2009 11:11:39 +0000 (11:11 +0000)
It's possible the data file has multiple matching ucode, we needn't to
update multiple times, just keep searching the latest version, and
update once.

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
xen/arch/x86/microcode_intel.c

index 8681a6945f525164f7cc51c95181b95e0bca2a52..c93df509adb06b2eaea64d18245add6506eaa425 100644 (file)
@@ -325,6 +325,7 @@ static int cpu_request_microcode(int cpu, const void *buf, size_t size)
     long offset = 0;
     int error = 0;
     void *mc;
+    unsigned int matching_count = 0;
 
     /* We should bind the task to the CPU */
     BUG_ON(cpu != raw_smp_processor_id());
@@ -343,7 +344,7 @@ static int cpu_request_microcode(int cpu, const void *buf, size_t size)
          */
         if ( error == 1 )
         {
-            apply_microcode(cpu);
+            matching_count++;
             error = 0;
         }
         xfree(mc);
@@ -353,6 +354,9 @@ static int cpu_request_microcode(int cpu, const void *buf, size_t size)
     if ( offset < 0 )
         error = offset;
 
+    if ( !error && matching_count )
+        apply_microcode(cpu);
+
     return error;
 }