@@ -1474,12 +1474,22 @@ int mce_threshold_remove_device(unsigned int cpu)
1474
1474
return 0 ;
1475
1475
}
1476
1476
1477
- /* create dir/files for all valid threshold banks */
1477
+ /**
1478
+ * mce_threshold_create_device - Create the per-CPU MCE threshold device
1479
+ * @cpu: The plugged in CPU
1480
+ *
1481
+ * Create directories and files for all valid threshold banks.
1482
+ *
1483
+ * This is invoked from the CPU hotplug callback which was installed in
1484
+ * mcheck_init_device(). The invocation happens in context of the hotplug
1485
+ * thread running on @cpu. The callback is invoked on all CPUs which are
1486
+ * online when the callback is installed or during a real hotplug event.
1487
+ */
1478
1488
int mce_threshold_create_device (unsigned int cpu )
1479
1489
{
1480
1490
unsigned int bank ;
1481
1491
struct threshold_bank * * bp ;
1482
- int err = 0 ;
1492
+ int err ;
1483
1493
1484
1494
if (!mce_flags .amd_threshold )
1485
1495
return 0 ;
@@ -1500,49 +1510,14 @@ int mce_threshold_create_device(unsigned int cpu)
1500
1510
continue ;
1501
1511
err = threshold_create_bank (cpu , bank );
1502
1512
if (err )
1503
- goto err ;
1504
- }
1505
- return err ;
1506
- err :
1507
- mce_threshold_remove_device (cpu );
1508
- return err ;
1509
- }
1510
-
1511
- static __init int threshold_init_device (void )
1512
- {
1513
- unsigned lcpu = 0 ;
1514
-
1515
- /* to hit CPUs online before the notifier is up */
1516
- for_each_online_cpu (lcpu ) {
1517
- int err = mce_threshold_create_device (lcpu );
1518
-
1519
- if (err )
1520
- return err ;
1513
+ goto out_err ;
1521
1514
}
1522
1515
1523
1516
if (thresholding_irq_en )
1524
1517
mce_threshold_vector = amd_threshold_interrupt ;
1525
1518
1526
1519
return 0 ;
1520
+ out_err :
1521
+ mce_threshold_remove_device (cpu );
1522
+ return err ;
1527
1523
}
1528
- /*
1529
- * there are 3 funcs which need to be _initcalled in a logic sequence:
1530
- * 1. xen_late_init_mcelog
1531
- * 2. mcheck_init_device
1532
- * 3. threshold_init_device
1533
- *
1534
- * xen_late_init_mcelog must register xen_mce_chrdev_device before
1535
- * native mce_chrdev_device registration if running under xen platform;
1536
- *
1537
- * mcheck_init_device should be inited before threshold_init_device to
1538
- * initialize mce_device, otherwise a NULL ptr dereference will cause panic.
1539
- *
1540
- * so we use following _initcalls
1541
- * 1. device_initcall(xen_late_init_mcelog);
1542
- * 2. device_initcall_sync(mcheck_init_device);
1543
- * 3. late_initcall(threshold_init_device);
1544
- *
1545
- * when running under xen, the initcall order is 1,2,3;
1546
- * on baremetal, we skip 1 and we do only 2 and 3.
1547
- */
1548
- late_initcall (threshold_init_device );
0 commit comments