sclp_config.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright IBM Corp. 2007
  3. * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
  4. */
  5. #define KMSG_COMPONENT "sclp_config"
  6. #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
  7. #include <linux/init.h>
  8. #include <linux/errno.h>
  9. #include <linux/cpu.h>
  10. #include <linux/device.h>
  11. #include <linux/workqueue.h>
  12. #include <asm/smp.h>
  13. #include "sclp.h"
  14. struct conf_mgm_data {
  15. u8 reserved;
  16. u8 ev_qualifier;
  17. } __attribute__((packed));
  18. #define EV_QUAL_CPU_CHANGE 1
  19. #define EV_QUAL_CAP_CHANGE 3
  20. static struct work_struct sclp_cpu_capability_work;
  21. static struct work_struct sclp_cpu_change_work;
  22. static void sclp_cpu_capability_notify(struct work_struct *work)
  23. {
  24. int cpu;
  25. struct device *dev;
  26. s390_adjust_jiffies();
  27. pr_warning("cpu capability changed.\n");
  28. get_online_cpus();
  29. for_each_online_cpu(cpu) {
  30. dev = get_cpu_device(cpu);
  31. kobject_uevent(&dev->kobj, KOBJ_CHANGE);
  32. }
  33. put_online_cpus();
  34. }
  35. static void __ref sclp_cpu_change_notify(struct work_struct *work)
  36. {
  37. smp_rescan_cpus();
  38. }
  39. static void sclp_conf_receiver_fn(struct evbuf_header *evbuf)
  40. {
  41. struct conf_mgm_data *cdata;
  42. cdata = (struct conf_mgm_data *)(evbuf + 1);
  43. switch (cdata->ev_qualifier) {
  44. case EV_QUAL_CPU_CHANGE:
  45. schedule_work(&sclp_cpu_change_work);
  46. break;
  47. case EV_QUAL_CAP_CHANGE:
  48. schedule_work(&sclp_cpu_capability_work);
  49. break;
  50. }
  51. }
  52. static struct sclp_register sclp_conf_register =
  53. {
  54. .receive_mask = EVTYP_CONFMGMDATA_MASK,
  55. .receiver_fn = sclp_conf_receiver_fn,
  56. };
  57. static int __init sclp_conf_init(void)
  58. {
  59. INIT_WORK(&sclp_cpu_capability_work, sclp_cpu_capability_notify);
  60. INIT_WORK(&sclp_cpu_change_work, sclp_cpu_change_notify);
  61. return sclp_register(&sclp_conf_register);
  62. }
  63. __initcall(sclp_conf_init);