mce_amd.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. /*
  2. * (c) 2005, 2006 Advanced Micro Devices, Inc.
  3. * Your use of this code is subject to the terms and conditions of the
  4. * GNU general public license version 2. See "COPYING" or
  5. * http://www.gnu.org/licenses/gpl.html
  6. *
  7. * Written by Jacob Shin - AMD, Inc.
  8. *
  9. * Support : jacob.shin@amd.com
  10. *
  11. * April 2006
  12. * - added support for AMD Family 0x10 processors
  13. *
  14. * All MC4_MISCi registers are shared between multi-cores
  15. */
  16. #include <linux/interrupt.h>
  17. #include <linux/notifier.h>
  18. #include <linux/kobject.h>
  19. #include <linux/percpu.h>
  20. #include <linux/sysdev.h>
  21. #include <linux/errno.h>
  22. #include <linux/sched.h>
  23. #include <linux/sysfs.h>
  24. #include <linux/slab.h>
  25. #include <linux/init.h>
  26. #include <linux/cpu.h>
  27. #include <linux/smp.h>
  28. #include <asm/apic.h>
  29. #include <asm/idle.h>
  30. #include <asm/mce.h>
  31. #include <asm/msr.h>
  32. #define PFX "mce_threshold: "
  33. #define VERSION "version 1.1.1"
  34. #define NR_BANKS 6
  35. #define NR_BLOCKS 9
  36. #define THRESHOLD_MAX 0xFFF
  37. #define INT_TYPE_APIC 0x00020000
  38. #define MASK_VALID_HI 0x80000000
  39. #define MASK_CNTP_HI 0x40000000
  40. #define MASK_LOCKED_HI 0x20000000
  41. #define MASK_LVTOFF_HI 0x00F00000
  42. #define MASK_COUNT_EN_HI 0x00080000
  43. #define MASK_INT_TYPE_HI 0x00060000
  44. #define MASK_OVERFLOW_HI 0x00010000
  45. #define MASK_ERR_COUNT_HI 0x00000FFF
  46. #define MASK_BLKPTR_LO 0xFF000000
  47. #define MCG_XBLK_ADDR 0xC0000400
  48. struct threshold_block {
  49. unsigned int block;
  50. unsigned int bank;
  51. unsigned int cpu;
  52. u32 address;
  53. u16 interrupt_enable;
  54. u16 threshold_limit;
  55. struct kobject kobj;
  56. struct list_head miscj;
  57. };
  58. struct threshold_bank {
  59. struct kobject *kobj;
  60. struct threshold_block *blocks;
  61. cpumask_var_t cpus;
  62. };
  63. static DEFINE_PER_CPU(struct threshold_bank * [NR_BANKS], threshold_banks);
  64. #ifdef CONFIG_SMP
  65. static unsigned char shared_bank[NR_BANKS] = {
  66. 0, 0, 0, 0, 1
  67. };
  68. #endif
  69. static DEFINE_PER_CPU(unsigned char, bank_map); /* see which banks are on */
  70. static void amd_threshold_interrupt(void);
  71. /*
  72. * CPU Initialization
  73. */
  74. struct thresh_restart {
  75. struct threshold_block *b;
  76. int reset;
  77. int set_lvt_off;
  78. int lvt_off;
  79. u16 old_limit;
  80. };
  81. /* must be called with correct cpu affinity */
  82. /* Called via smp_call_function_single() */
  83. static void threshold_restart_bank(void *_tr)
  84. {
  85. struct thresh_restart *tr = _tr;
  86. u32 hi, lo;
  87. rdmsr(tr->b->address, lo, hi);
  88. if (tr->b->threshold_limit < (hi & THRESHOLD_MAX))
  89. tr->reset = 1; /* limit cannot be lower than err count */
  90. if (tr->reset) { /* reset err count and overflow bit */
  91. hi =
  92. (hi & ~(MASK_ERR_COUNT_HI | MASK_OVERFLOW_HI)) |
  93. (THRESHOLD_MAX - tr->b->threshold_limit);
  94. } else if (tr->old_limit) { /* change limit w/o reset */
  95. int new_count = (hi & THRESHOLD_MAX) +
  96. (tr->old_limit - tr->b->threshold_limit);
  97. hi = (hi & ~MASK_ERR_COUNT_HI) |
  98. (new_count & THRESHOLD_MAX);
  99. }
  100. if (tr->set_lvt_off) {
  101. /* set new lvt offset */
  102. hi &= ~MASK_LVTOFF_HI;
  103. hi |= tr->lvt_off << 20;
  104. }
  105. tr->b->interrupt_enable ?
  106. (hi = (hi & ~MASK_INT_TYPE_HI) | INT_TYPE_APIC) :
  107. (hi &= ~MASK_INT_TYPE_HI);
  108. hi |= MASK_COUNT_EN_HI;
  109. wrmsr(tr->b->address, lo, hi);
  110. }
  111. static void mce_threshold_block_init(struct threshold_block *b, int offset)
  112. {
  113. struct thresh_restart tr = {
  114. .b = b,
  115. .set_lvt_off = 1,
  116. .lvt_off = offset,
  117. };
  118. b->threshold_limit = THRESHOLD_MAX;
  119. threshold_restart_bank(&tr);
  120. };
  121. /* cpu init entry point, called from mce.c with preempt off */
  122. void mce_amd_feature_init(struct cpuinfo_x86 *c)
  123. {
  124. struct threshold_block b;
  125. unsigned int cpu = smp_processor_id();
  126. u32 low = 0, high = 0, address = 0;
  127. unsigned int bank, block;
  128. int lvt_off = -1;
  129. u8 offset;
  130. for (bank = 0; bank < NR_BANKS; ++bank) {
  131. for (block = 0; block < NR_BLOCKS; ++block) {
  132. if (block == 0)
  133. address = MSR_IA32_MC0_MISC + bank * 4;
  134. else if (block == 1) {
  135. address = (low & MASK_BLKPTR_LO) >> 21;
  136. if (!address)
  137. break;
  138. address += MCG_XBLK_ADDR;
  139. } else
  140. ++address;
  141. if (rdmsr_safe(address, &low, &high))
  142. break;
  143. if (!(high & MASK_VALID_HI))
  144. continue;
  145. if (!(high & MASK_CNTP_HI) ||
  146. (high & MASK_LOCKED_HI))
  147. continue;
  148. if (!block)
  149. per_cpu(bank_map, cpu) |= (1 << bank);
  150. #ifdef CONFIG_SMP
  151. if (shared_bank[bank] && c->cpu_core_id)
  152. break;
  153. #endif
  154. offset = (high & MASK_LVTOFF_HI) >> 20;
  155. if (lvt_off < 0) {
  156. if (setup_APIC_eilvt(offset,
  157. THRESHOLD_APIC_VECTOR,
  158. APIC_EILVT_MSG_FIX, 0)) {
  159. pr_err(FW_BUG "cpu %d, failed to "
  160. "setup threshold interrupt "
  161. "for bank %d, block %d "
  162. "(MSR%08X=0x%x%08x)",
  163. smp_processor_id(), bank, block,
  164. address, high, low);
  165. continue;
  166. }
  167. lvt_off = offset;
  168. } else if (lvt_off != offset) {
  169. pr_err(FW_BUG "cpu %d, invalid threshold "
  170. "interrupt offset %d for bank %d,"
  171. "block %d (MSR%08X=0x%x%08x)",
  172. smp_processor_id(), lvt_off, bank,
  173. block, address, high, low);
  174. continue;
  175. }
  176. memset(&b, 0, sizeof(b));
  177. b.cpu = cpu;
  178. b.bank = bank;
  179. b.block = block;
  180. b.address = address;
  181. mce_threshold_block_init(&b, offset);
  182. mce_threshold_vector = amd_threshold_interrupt;
  183. }
  184. }
  185. }
  186. /*
  187. * APIC Interrupt Handler
  188. */
  189. /*
  190. * threshold interrupt handler will service THRESHOLD_APIC_VECTOR.
  191. * the interrupt goes off when error_count reaches threshold_limit.
  192. * the handler will simply log mcelog w/ software defined bank number.
  193. */
  194. static void amd_threshold_interrupt(void)
  195. {
  196. u32 low = 0, high = 0, address = 0;
  197. unsigned int bank, block;
  198. struct mce m;
  199. mce_setup(&m);
  200. /* assume first bank caused it */
  201. for (bank = 0; bank < NR_BANKS; ++bank) {
  202. if (!(per_cpu(bank_map, m.cpu) & (1 << bank)))
  203. continue;
  204. for (block = 0; block < NR_BLOCKS; ++block) {
  205. if (block == 0) {
  206. address = MSR_IA32_MC0_MISC + bank * 4;
  207. } else if (block == 1) {
  208. address = (low & MASK_BLKPTR_LO) >> 21;
  209. if (!address)
  210. break;
  211. address += MCG_XBLK_ADDR;
  212. } else {
  213. ++address;
  214. }
  215. if (rdmsr_safe(address, &low, &high))
  216. break;
  217. if (!(high & MASK_VALID_HI)) {
  218. if (block)
  219. continue;
  220. else
  221. break;
  222. }
  223. if (!(high & MASK_CNTP_HI) ||
  224. (high & MASK_LOCKED_HI))
  225. continue;
  226. /*
  227. * Log the machine check that caused the threshold
  228. * event.
  229. */
  230. machine_check_poll(MCP_TIMESTAMP,
  231. &__get_cpu_var(mce_poll_banks));
  232. if (high & MASK_OVERFLOW_HI) {
  233. rdmsrl(address, m.misc);
  234. rdmsrl(MSR_IA32_MC0_STATUS + bank * 4,
  235. m.status);
  236. m.bank = K8_MCE_THRESHOLD_BASE
  237. + bank * NR_BLOCKS
  238. + block;
  239. mce_log(&m);
  240. return;
  241. }
  242. }
  243. }
  244. }
  245. /*
  246. * Sysfs Interface
  247. */
  248. struct threshold_attr {
  249. struct attribute attr;
  250. ssize_t (*show) (struct threshold_block *, char *);
  251. ssize_t (*store) (struct threshold_block *, const char *, size_t count);
  252. };
  253. #define SHOW_FIELDS(name) \
  254. static ssize_t show_ ## name(struct threshold_block *b, char *buf) \
  255. { \
  256. return sprintf(buf, "%lx\n", (unsigned long) b->name); \
  257. }
  258. SHOW_FIELDS(interrupt_enable)
  259. SHOW_FIELDS(threshold_limit)
  260. static ssize_t
  261. store_interrupt_enable(struct threshold_block *b, const char *buf, size_t size)
  262. {
  263. struct thresh_restart tr;
  264. unsigned long new;
  265. if (strict_strtoul(buf, 0, &new) < 0)
  266. return -EINVAL;
  267. b->interrupt_enable = !!new;
  268. memset(&tr, 0, sizeof(tr));
  269. tr.b = b;
  270. smp_call_function_single(b->cpu, threshold_restart_bank, &tr, 1);
  271. return size;
  272. }
  273. static ssize_t
  274. store_threshold_limit(struct threshold_block *b, const char *buf, size_t size)
  275. {
  276. struct thresh_restart tr;
  277. unsigned long new;
  278. if (strict_strtoul(buf, 0, &new) < 0)
  279. return -EINVAL;
  280. if (new > THRESHOLD_MAX)
  281. new = THRESHOLD_MAX;
  282. if (new < 1)
  283. new = 1;
  284. memset(&tr, 0, sizeof(tr));
  285. tr.old_limit = b->threshold_limit;
  286. b->threshold_limit = new;
  287. tr.b = b;
  288. smp_call_function_single(b->cpu, threshold_restart_bank, &tr, 1);
  289. return size;
  290. }
  291. struct threshold_block_cross_cpu {
  292. struct threshold_block *tb;
  293. long retval;
  294. };
  295. static void local_error_count_handler(void *_tbcc)
  296. {
  297. struct threshold_block_cross_cpu *tbcc = _tbcc;
  298. struct threshold_block *b = tbcc->tb;
  299. u32 low, high;
  300. rdmsr(b->address, low, high);
  301. tbcc->retval = (high & 0xFFF) - (THRESHOLD_MAX - b->threshold_limit);
  302. }
  303. static ssize_t show_error_count(struct threshold_block *b, char *buf)
  304. {
  305. struct threshold_block_cross_cpu tbcc = { .tb = b, };
  306. smp_call_function_single(b->cpu, local_error_count_handler, &tbcc, 1);
  307. return sprintf(buf, "%lx\n", tbcc.retval);
  308. }
  309. static ssize_t store_error_count(struct threshold_block *b,
  310. const char *buf, size_t count)
  311. {
  312. struct thresh_restart tr = { .b = b, .reset = 1, .old_limit = 0 };
  313. smp_call_function_single(b->cpu, threshold_restart_bank, &tr, 1);
  314. return 1;
  315. }
  316. #define RW_ATTR(val) \
  317. static struct threshold_attr val = { \
  318. .attr = {.name = __stringify(val), .mode = 0644 }, \
  319. .show = show_## val, \
  320. .store = store_## val, \
  321. };
  322. RW_ATTR(interrupt_enable);
  323. RW_ATTR(threshold_limit);
  324. RW_ATTR(error_count);
  325. static struct attribute *default_attrs[] = {
  326. &interrupt_enable.attr,
  327. &threshold_limit.attr,
  328. &error_count.attr,
  329. NULL
  330. };
  331. #define to_block(k) container_of(k, struct threshold_block, kobj)
  332. #define to_attr(a) container_of(a, struct threshold_attr, attr)
  333. static ssize_t show(struct kobject *kobj, struct attribute *attr, char *buf)
  334. {
  335. struct threshold_block *b = to_block(kobj);
  336. struct threshold_attr *a = to_attr(attr);
  337. ssize_t ret;
  338. ret = a->show ? a->show(b, buf) : -EIO;
  339. return ret;
  340. }
  341. static ssize_t store(struct kobject *kobj, struct attribute *attr,
  342. const char *buf, size_t count)
  343. {
  344. struct threshold_block *b = to_block(kobj);
  345. struct threshold_attr *a = to_attr(attr);
  346. ssize_t ret;
  347. ret = a->store ? a->store(b, buf, count) : -EIO;
  348. return ret;
  349. }
  350. static const struct sysfs_ops threshold_ops = {
  351. .show = show,
  352. .store = store,
  353. };
  354. static struct kobj_type threshold_ktype = {
  355. .sysfs_ops = &threshold_ops,
  356. .default_attrs = default_attrs,
  357. };
  358. static __cpuinit int allocate_threshold_blocks(unsigned int cpu,
  359. unsigned int bank,
  360. unsigned int block,
  361. u32 address)
  362. {
  363. struct threshold_block *b = NULL;
  364. u32 low, high;
  365. int err;
  366. if ((bank >= NR_BANKS) || (block >= NR_BLOCKS))
  367. return 0;
  368. if (rdmsr_safe_on_cpu(cpu, address, &low, &high))
  369. return 0;
  370. if (!(high & MASK_VALID_HI)) {
  371. if (block)
  372. goto recurse;
  373. else
  374. return 0;
  375. }
  376. if (!(high & MASK_CNTP_HI) ||
  377. (high & MASK_LOCKED_HI))
  378. goto recurse;
  379. b = kzalloc(sizeof(struct threshold_block), GFP_KERNEL);
  380. if (!b)
  381. return -ENOMEM;
  382. b->block = block;
  383. b->bank = bank;
  384. b->cpu = cpu;
  385. b->address = address;
  386. b->interrupt_enable = 0;
  387. b->threshold_limit = THRESHOLD_MAX;
  388. INIT_LIST_HEAD(&b->miscj);
  389. if (per_cpu(threshold_banks, cpu)[bank]->blocks) {
  390. list_add(&b->miscj,
  391. &per_cpu(threshold_banks, cpu)[bank]->blocks->miscj);
  392. } else {
  393. per_cpu(threshold_banks, cpu)[bank]->blocks = b;
  394. }
  395. err = kobject_init_and_add(&b->kobj, &threshold_ktype,
  396. per_cpu(threshold_banks, cpu)[bank]->kobj,
  397. "misc%i", block);
  398. if (err)
  399. goto out_free;
  400. recurse:
  401. if (!block) {
  402. address = (low & MASK_BLKPTR_LO) >> 21;
  403. if (!address)
  404. return 0;
  405. address += MCG_XBLK_ADDR;
  406. } else {
  407. ++address;
  408. }
  409. err = allocate_threshold_blocks(cpu, bank, ++block, address);
  410. if (err)
  411. goto out_free;
  412. if (b)
  413. kobject_uevent(&b->kobj, KOBJ_ADD);
  414. return err;
  415. out_free:
  416. if (b) {
  417. kobject_put(&b->kobj);
  418. kfree(b);
  419. }
  420. return err;
  421. }
  422. static __cpuinit long
  423. local_allocate_threshold_blocks(int cpu, unsigned int bank)
  424. {
  425. return allocate_threshold_blocks(cpu, bank, 0,
  426. MSR_IA32_MC0_MISC + bank * 4);
  427. }
  428. /* symlinks sibling shared banks to first core. first core owns dir/files. */
  429. static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
  430. {
  431. int i, err = 0;
  432. struct threshold_bank *b = NULL;
  433. char name[32];
  434. #ifdef CONFIG_SMP
  435. struct cpuinfo_x86 *c = &cpu_data(cpu);
  436. #endif
  437. sprintf(name, "threshold_bank%i", bank);
  438. #ifdef CONFIG_SMP
  439. if (cpu_data(cpu).cpu_core_id && shared_bank[bank]) { /* symlink */
  440. i = cpumask_first(c->llc_shared_map);
  441. /* first core not up yet */
  442. if (cpu_data(i).cpu_core_id)
  443. goto out;
  444. /* already linked */
  445. if (per_cpu(threshold_banks, cpu)[bank])
  446. goto out;
  447. b = per_cpu(threshold_banks, i)[bank];
  448. if (!b)
  449. goto out;
  450. err = sysfs_create_link(&per_cpu(mce_dev, cpu).kobj,
  451. b->kobj, name);
  452. if (err)
  453. goto out;
  454. cpumask_copy(b->cpus, c->llc_shared_map);
  455. per_cpu(threshold_banks, cpu)[bank] = b;
  456. goto out;
  457. }
  458. #endif
  459. b = kzalloc(sizeof(struct threshold_bank), GFP_KERNEL);
  460. if (!b) {
  461. err = -ENOMEM;
  462. goto out;
  463. }
  464. if (!zalloc_cpumask_var(&b->cpus, GFP_KERNEL)) {
  465. kfree(b);
  466. err = -ENOMEM;
  467. goto out;
  468. }
  469. b->kobj = kobject_create_and_add(name, &per_cpu(mce_dev, cpu).kobj);
  470. if (!b->kobj)
  471. goto out_free;
  472. #ifndef CONFIG_SMP
  473. cpumask_setall(b->cpus);
  474. #else
  475. cpumask_set_cpu(cpu, b->cpus);
  476. #endif
  477. per_cpu(threshold_banks, cpu)[bank] = b;
  478. err = local_allocate_threshold_blocks(cpu, bank);
  479. if (err)
  480. goto out_free;
  481. for_each_cpu(i, b->cpus) {
  482. if (i == cpu)
  483. continue;
  484. err = sysfs_create_link(&per_cpu(mce_dev, i).kobj,
  485. b->kobj, name);
  486. if (err)
  487. goto out;
  488. per_cpu(threshold_banks, i)[bank] = b;
  489. }
  490. goto out;
  491. out_free:
  492. per_cpu(threshold_banks, cpu)[bank] = NULL;
  493. free_cpumask_var(b->cpus);
  494. kfree(b);
  495. out:
  496. return err;
  497. }
  498. /* create dir/files for all valid threshold banks */
  499. static __cpuinit int threshold_create_device(unsigned int cpu)
  500. {
  501. unsigned int bank;
  502. int err = 0;
  503. for (bank = 0; bank < NR_BANKS; ++bank) {
  504. if (!(per_cpu(bank_map, cpu) & (1 << bank)))
  505. continue;
  506. err = threshold_create_bank(cpu, bank);
  507. if (err)
  508. goto out;
  509. }
  510. out:
  511. return err;
  512. }
  513. /*
  514. * let's be hotplug friendly.
  515. * in case of multiple core processors, the first core always takes ownership
  516. * of shared sysfs dir/files, and rest of the cores will be symlinked to it.
  517. */
  518. static void deallocate_threshold_block(unsigned int cpu,
  519. unsigned int bank)
  520. {
  521. struct threshold_block *pos = NULL;
  522. struct threshold_block *tmp = NULL;
  523. struct threshold_bank *head = per_cpu(threshold_banks, cpu)[bank];
  524. if (!head)
  525. return;
  526. list_for_each_entry_safe(pos, tmp, &head->blocks->miscj, miscj) {
  527. kobject_put(&pos->kobj);
  528. list_del(&pos->miscj);
  529. kfree(pos);
  530. }
  531. kfree(per_cpu(threshold_banks, cpu)[bank]->blocks);
  532. per_cpu(threshold_banks, cpu)[bank]->blocks = NULL;
  533. }
  534. static void threshold_remove_bank(unsigned int cpu, int bank)
  535. {
  536. struct threshold_bank *b;
  537. char name[32];
  538. int i = 0;
  539. b = per_cpu(threshold_banks, cpu)[bank];
  540. if (!b)
  541. return;
  542. if (!b->blocks)
  543. goto free_out;
  544. sprintf(name, "threshold_bank%i", bank);
  545. #ifdef CONFIG_SMP
  546. /* sibling symlink */
  547. if (shared_bank[bank] && b->blocks->cpu != cpu) {
  548. sysfs_remove_link(&per_cpu(mce_dev, cpu).kobj, name);
  549. per_cpu(threshold_banks, cpu)[bank] = NULL;
  550. return;
  551. }
  552. #endif
  553. /* remove all sibling symlinks before unregistering */
  554. for_each_cpu(i, b->cpus) {
  555. if (i == cpu)
  556. continue;
  557. sysfs_remove_link(&per_cpu(mce_dev, i).kobj, name);
  558. per_cpu(threshold_banks, i)[bank] = NULL;
  559. }
  560. deallocate_threshold_block(cpu, bank);
  561. free_out:
  562. kobject_del(b->kobj);
  563. kobject_put(b->kobj);
  564. free_cpumask_var(b->cpus);
  565. kfree(b);
  566. per_cpu(threshold_banks, cpu)[bank] = NULL;
  567. }
  568. static void threshold_remove_device(unsigned int cpu)
  569. {
  570. unsigned int bank;
  571. for (bank = 0; bank < NR_BANKS; ++bank) {
  572. if (!(per_cpu(bank_map, cpu) & (1 << bank)))
  573. continue;
  574. threshold_remove_bank(cpu, bank);
  575. }
  576. }
  577. /* get notified when a cpu comes on/off */
  578. static void __cpuinit
  579. amd_64_threshold_cpu_callback(unsigned long action, unsigned int cpu)
  580. {
  581. switch (action) {
  582. case CPU_ONLINE:
  583. case CPU_ONLINE_FROZEN:
  584. threshold_create_device(cpu);
  585. break;
  586. case CPU_DEAD:
  587. case CPU_DEAD_FROZEN:
  588. threshold_remove_device(cpu);
  589. break;
  590. default:
  591. break;
  592. }
  593. }
  594. static __init int threshold_init_device(void)
  595. {
  596. unsigned lcpu = 0;
  597. /* to hit CPUs online before the notifier is up */
  598. for_each_online_cpu(lcpu) {
  599. int err = threshold_create_device(lcpu);
  600. if (err)
  601. return err;
  602. }
  603. threshold_cpu_callback = amd_64_threshold_cpu_callback;
  604. return 0;
  605. }
  606. device_initcall(threshold_init_device);