sclp_config.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * drivers/s390/char/sclp_config.c
  3. *
  4. * Copyright IBM Corp. 2007
  5. * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
  6. */
  7. #include <linux/init.h>
  8. #include <linux/errno.h>
  9. #include <linux/cpu.h>
  10. #include <linux/sysdev.h>
  11. #include <linux/workqueue.h>
  12. #include "sclp.h"
  13. #define TAG "sclp_config: "
  14. struct conf_mgm_data {
  15. u8 reserved;
  16. u8 ev_qualifier;
  17. } __attribute__((packed));
  18. #define EV_QUAL_CAP_CHANGE 3
  19. static struct work_struct sclp_cpu_capability_work;
  20. static void sclp_cpu_capability_notify(struct work_struct *work)
  21. {
  22. int cpu;
  23. struct sys_device *sysdev;
  24. printk(KERN_WARNING TAG "cpu capability changed.\n");
  25. lock_cpu_hotplug();
  26. for_each_online_cpu(cpu) {
  27. sysdev = get_cpu_sysdev(cpu);
  28. kobject_uevent(&sysdev->kobj, KOBJ_CHANGE);
  29. }
  30. unlock_cpu_hotplug();
  31. }
  32. static void sclp_conf_receiver_fn(struct evbuf_header *evbuf)
  33. {
  34. struct conf_mgm_data *cdata;
  35. cdata = (struct conf_mgm_data *)(evbuf + 1);
  36. if (cdata->ev_qualifier == EV_QUAL_CAP_CHANGE)
  37. schedule_work(&sclp_cpu_capability_work);
  38. }
  39. static struct sclp_register sclp_conf_register =
  40. {
  41. .receive_mask = EVTYP_CONFMGMDATA_MASK,
  42. .receiver_fn = sclp_conf_receiver_fn,
  43. };
  44. static int __init sclp_conf_init(void)
  45. {
  46. int rc;
  47. INIT_WORK(&sclp_cpu_capability_work, sclp_cpu_capability_notify);
  48. rc = sclp_register(&sclp_conf_register);
  49. if (rc) {
  50. printk(KERN_ERR TAG "failed to register (%d).\n", rc);
  51. return rc;
  52. }
  53. if (!(sclp_conf_register.sclp_receive_mask & EVTYP_CONFMGMDATA_MASK)) {
  54. printk(KERN_WARNING TAG "no configuration management.\n");
  55. sclp_unregister(&sclp_conf_register);
  56. rc = -ENOSYS;
  57. }
  58. return rc;
  59. }
  60. __initcall(sclp_conf_init);