aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2011-09-28 11:11:00 -0400
committerGuenter Roeck <guenter.roeck@ericsson.com>2011-09-28 11:19:20 -0400
commit0eb9782ad9b1bd496ba61cd5ea27ccb8db21e885 (patch)
tree9ef8d8f799df410990aa48ca5fd7518b9ba24495
parenta102a9ece5489e1718cd7543aa079082450ac3a2 (diff)
hwmon: (coretemp) Fixup platform device ID change
With recent change "hwmon: (coretemp) don't use kernel assigned CPU number as platform device ID", the microcode check is now running on random CPU. Fix that by checking the microcode before creating the platform device rather than at probe time. Also avoid calling TO_PHYS_ID(cpu) twice in the same function, it's expensive. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: Jan Beulich <jbeulich@suse.com> Cc: Guenter Roeck <guenter.roeck@ericsson.com> Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
-rw-r--r--drivers/hwmon/coretemp.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 44b23917d4cc..cf5b1de32c0a 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -377,9 +377,9 @@ exit_free:
377} 377}
378 378
379 379
380static int __devinit chk_ucode_version(struct platform_device *pdev) 380static int __cpuinit chk_ucode_version(unsigned int cpu)
381{ 381{
382 struct cpuinfo_x86 *c = &cpu_data(pdev->id); 382 struct cpuinfo_x86 *c = &cpu_data(cpu);
383 int err; 383 int err;
384 u32 edx; 384 u32 edx;
385 385
@@ -390,17 +390,15 @@ static int __devinit chk_ucode_version(struct platform_device *pdev)
390 */ 390 */
391 if (c->x86_model == 0xe && c->x86_mask < 0xc) { 391 if (c->x86_model == 0xe && c->x86_mask < 0xc) {
392 /* check for microcode update */ 392 /* check for microcode update */
393 err = smp_call_function_single(pdev->id, get_ucode_rev_on_cpu, 393 err = smp_call_function_single(cpu, get_ucode_rev_on_cpu,
394 &edx, 1); 394 &edx, 1);
395 if (err) { 395 if (err) {
396 dev_err(&pdev->dev, 396 pr_err("Cannot determine microcode revision of "
397 "Cannot determine microcode revision of " 397 "CPU#%u (%d)!\n", cpu, err);
398 "CPU#%u (%d)!\n", pdev->id, err);
399 return -ENODEV; 398 return -ENODEV;
400 } else if (edx < 0x39) { 399 } else if (edx < 0x39) {
401 dev_err(&pdev->dev, 400 pr_err("Errata AE18 not fixed, update BIOS or "
402 "Errata AE18 not fixed, update BIOS or " 401 "microcode of the CPU!\n");
403 "microcode of the CPU!\n");
404 return -ENODEV; 402 return -ENODEV;
405 } 403 }
406 } 404 }
@@ -544,11 +542,6 @@ static int __devinit coretemp_probe(struct platform_device *pdev)
544 struct platform_data *pdata; 542 struct platform_data *pdata;
545 int err; 543 int err;
546 544
547 /* Check the microcode version of the CPU */
548 err = chk_ucode_version(pdev);
549 if (err)
550 return err;
551
552 /* Initialize the per-package data structures */ 545 /* Initialize the per-package data structures */
553 pdata = kzalloc(sizeof(struct platform_data), GFP_KERNEL); 546 pdata = kzalloc(sizeof(struct platform_data), GFP_KERNEL);
554 if (!pdata) 547 if (!pdata)
@@ -630,7 +623,7 @@ static int __cpuinit coretemp_device_add(unsigned int cpu)
630 } 623 }
631 624
632 pdev_entry->pdev = pdev; 625 pdev_entry->pdev = pdev;
633 pdev_entry->phys_proc_id = TO_PHYS_ID(cpu); 626 pdev_entry->phys_proc_id = pdev->id;
634 627
635 list_add_tail(&pdev_entry->list, &pdev_list); 628 list_add_tail(&pdev_entry->list, &pdev_list);
636 mutex_unlock(&pdev_list_mutex); 629 mutex_unlock(&pdev_list_mutex);
@@ -691,6 +684,10 @@ static void __cpuinit get_core_online(unsigned int cpu)
691 return; 684 return;
692 685
693 if (!pdev) { 686 if (!pdev) {
687 /* Check the microcode version of the CPU */
688 if (chk_ucode_version(cpu))
689 return;
690
694 /* 691 /*
695 * Alright, we have DTS support. 692 * Alright, we have DTS support.
696 * We are bringing the _first_ core in this pkg 693 * We are bringing the _first_ core in this pkg