aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Herrmann <herrmann.der.user@googlemail.com>2009-11-10 06:07:23 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-10 06:15:48 -0500
commitd1c84f79a6ba992dc01e312c44a21496303874d6 (patch)
tree1d15af2e65759cc25132cdfffebea7f710bfdb07
parent6e18da75c28b592594fd632cf3e6eb09d3d078de (diff)
x86: ucode-amd: Load ucode-patches once and not separately of each CPU
This also implies that corresponding log messages, e.g. platform microcode: firmware: requesting amd-ucode/microcode_amd.bin show up only once on module load and not when ucode is updated for each CPU. Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com> Cc: dimm <dmitry.adamushko@gmail.com> LKML-Reference: <20091110110723.GH30802@alberich.amd.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--arch/x86/include/asm/microcode.h2
-rw-r--r--arch/x86/kernel/microcode_amd.c24
-rw-r--r--arch/x86/kernel/microcode_core.c6
3 files changed, 25 insertions, 7 deletions
diff --git a/arch/x86/include/asm/microcode.h b/arch/x86/include/asm/microcode.h
index ef51b501e22a..c24ca9a56458 100644
--- a/arch/x86/include/asm/microcode.h
+++ b/arch/x86/include/asm/microcode.h
@@ -12,6 +12,8 @@ struct device;
12enum ucode_state { UCODE_ERROR, UCODE_OK, UCODE_NFOUND }; 12enum ucode_state { UCODE_ERROR, UCODE_OK, UCODE_NFOUND };
13 13
14struct microcode_ops { 14struct microcode_ops {
15 void (*init)(struct device *device);
16 void (*fini)(void);
15 enum ucode_state (*request_microcode_user) (int cpu, 17 enum ucode_state (*request_microcode_user) (int cpu,
16 const void __user *buf, size_t size); 18 const void __user *buf, size_t size);
17 19
diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c
index c043534fd986..75538f647193 100644
--- a/arch/x86/kernel/microcode_amd.c
+++ b/arch/x86/kernel/microcode_amd.c
@@ -33,6 +33,8 @@ MODULE_LICENSE("GPL v2");
33#define UCODE_EQUIV_CPU_TABLE_TYPE 0x00000000 33#define UCODE_EQUIV_CPU_TABLE_TYPE 0x00000000
34#define UCODE_UCODE_TYPE 0x00000001 34#define UCODE_UCODE_TYPE 0x00000001
35 35
36const struct firmware *firmware;
37
36struct equiv_cpu_entry { 38struct equiv_cpu_entry {
37 u32 installed_cpu; 39 u32 installed_cpu;
38 u32 fixed_errata_mask; 40 u32 fixed_errata_mask;
@@ -301,14 +303,10 @@ generic_load_microcode(int cpu, const u8 *data, size_t size)
301 303
302static enum ucode_state request_microcode_fw(int cpu, struct device *device) 304static enum ucode_state request_microcode_fw(int cpu, struct device *device)
303{ 305{
304 const char *fw_name = "amd-ucode/microcode_amd.bin";
305 const struct firmware *firmware;
306 enum ucode_state ret; 306 enum ucode_state ret;
307 307
308 if (request_firmware(&firmware, fw_name, device)) { 308 if (firmware == NULL)
309 printk(KERN_ERR "microcode: failed to load file %s\n", fw_name);
310 return UCODE_NFOUND; 309 return UCODE_NFOUND;
311 }
312 310
313 if (*(u32 *)firmware->data != UCODE_MAGIC) { 311 if (*(u32 *)firmware->data != UCODE_MAGIC) {
314 printk(KERN_ERR "microcode: invalid UCODE_MAGIC (0x%08x)\n", 312 printk(KERN_ERR "microcode: invalid UCODE_MAGIC (0x%08x)\n",
@@ -318,8 +316,6 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device)
318 316
319 ret = generic_load_microcode(cpu, firmware->data, firmware->size); 317 ret = generic_load_microcode(cpu, firmware->data, firmware->size);
320 318
321 release_firmware(firmware);
322
323 return ret; 319 return ret;
324} 320}
325 321
@@ -339,7 +335,21 @@ static void microcode_fini_cpu_amd(int cpu)
339 uci->mc = NULL; 335 uci->mc = NULL;
340} 336}
341 337
338void init_microcode_amd(struct device *device)
339{
340 const char *fw_name = "amd-ucode/microcode_amd.bin";
341 if (request_firmware(&firmware, fw_name, device))
342 printk(KERN_ERR "microcode: failed to load file %s\n", fw_name);
343}
344
345void fini_microcode_amd(void)
346{
347 release_firmware(firmware);
348}
349
342static struct microcode_ops microcode_amd_ops = { 350static struct microcode_ops microcode_amd_ops = {
351 .init = init_microcode_amd,
352 .fini = fini_microcode_amd,
343 .request_microcode_user = request_microcode_user, 353 .request_microcode_user = request_microcode_user,
344 .request_microcode_fw = request_microcode_fw, 354 .request_microcode_fw = request_microcode_fw,
345 .collect_cpu_info = collect_cpu_info_amd, 355 .collect_cpu_info = collect_cpu_info_amd,
diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
index 378e9a8f1bf8..d2a816021d9f 100644
--- a/arch/x86/kernel/microcode_core.c
+++ b/arch/x86/kernel/microcode_core.c
@@ -520,6 +520,9 @@ static int __init microcode_init(void)
520 return PTR_ERR(microcode_pdev); 520 return PTR_ERR(microcode_pdev);
521 } 521 }
522 522
523 if (microcode_ops->init)
524 microcode_ops->init(&microcode_pdev->dev);
525
523 get_online_cpus(); 526 get_online_cpus();
524 mutex_lock(&microcode_mutex); 527 mutex_lock(&microcode_mutex);
525 528
@@ -563,6 +566,9 @@ static void __exit microcode_exit(void)
563 566
564 platform_device_unregister(microcode_pdev); 567 platform_device_unregister(microcode_pdev);
565 568
569 if (microcode_ops->fini)
570 microcode_ops->fini();
571
566 microcode_ops = NULL; 572 microcode_ops = NULL;
567 573
568 pr_info("Microcode Update Driver: v" MICROCODE_VERSION " removed.\n"); 574 pr_info("Microcode Update Driver: v" MICROCODE_VERSION " removed.\n");