Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 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 | |
Martin Schwidefsky | b3ff088 | 2008-12-25 13:39:48 +0100 | [diff] [blame] | 8 | #define KMSG_COMPONENT "sclp_config" |
| 9 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
| 10 | |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 11 | #include <linux/init.h> |
| 12 | #include <linux/errno.h> |
| 13 | #include <linux/cpu.h> |
| 14 | #include <linux/sysdev.h> |
| 15 | #include <linux/workqueue.h> |
Heiko Carstens | 1e48951 | 2008-04-30 13:38:37 +0200 | [diff] [blame] | 16 | #include <asm/smp.h> |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 17 | |
Martin Schwidefsky | b3ff088 | 2008-12-25 13:39:48 +0100 | [diff] [blame] | 18 | #include "sclp.h" |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 19 | |
| 20 | struct conf_mgm_data { |
| 21 | u8 reserved; |
| 22 | u8 ev_qualifier; |
| 23 | } __attribute__((packed)); |
| 24 | |
Heiko Carstens | 1e48951 | 2008-04-30 13:38:37 +0200 | [diff] [blame] | 25 | #define EV_QUAL_CPU_CHANGE 1 |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 26 | #define EV_QUAL_CAP_CHANGE 3 |
| 27 | |
| 28 | static struct work_struct sclp_cpu_capability_work; |
Heiko Carstens | 1e48951 | 2008-04-30 13:38:37 +0200 | [diff] [blame] | 29 | static struct work_struct sclp_cpu_change_work; |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 30 | |
| 31 | static void sclp_cpu_capability_notify(struct work_struct *work) |
| 32 | { |
| 33 | int cpu; |
| 34 | struct sys_device *sysdev; |
| 35 | |
Martin Schwidefsky | b3ff088 | 2008-12-25 13:39:48 +0100 | [diff] [blame] | 36 | pr_warning("cpu capability changed.\n"); |
Gautham R Shenoy | 86ef5c9 | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 37 | get_online_cpus(); |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 38 | for_each_online_cpu(cpu) { |
| 39 | sysdev = get_cpu_sysdev(cpu); |
| 40 | kobject_uevent(&sysdev->kobj, KOBJ_CHANGE); |
| 41 | } |
Gautham R Shenoy | 86ef5c9 | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 42 | put_online_cpus(); |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 43 | } |
| 44 | |
Heiko Carstens | b9732ca | 2008-07-14 09:57:28 +0200 | [diff] [blame] | 45 | static void __ref sclp_cpu_change_notify(struct work_struct *work) |
| 46 | { |
Heiko Carstens | fc7e1e4 | 2008-08-01 16:39:23 +0200 | [diff] [blame] | 47 | smp_rescan_cpus(); |
Heiko Carstens | 1e48951 | 2008-04-30 13:38:37 +0200 | [diff] [blame] | 48 | } |
| 49 | |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 50 | static void sclp_conf_receiver_fn(struct evbuf_header *evbuf) |
| 51 | { |
| 52 | struct conf_mgm_data *cdata; |
| 53 | |
| 54 | cdata = (struct conf_mgm_data *)(evbuf + 1); |
Heiko Carstens | 1e48951 | 2008-04-30 13:38:37 +0200 | [diff] [blame] | 55 | switch (cdata->ev_qualifier) { |
| 56 | case EV_QUAL_CPU_CHANGE: |
| 57 | schedule_work(&sclp_cpu_change_work); |
| 58 | break; |
| 59 | case EV_QUAL_CAP_CHANGE: |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 60 | schedule_work(&sclp_cpu_capability_work); |
Heiko Carstens | 1e48951 | 2008-04-30 13:38:37 +0200 | [diff] [blame] | 61 | break; |
| 62 | } |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | static struct sclp_register sclp_conf_register = |
| 66 | { |
| 67 | .receive_mask = EVTYP_CONFMGMDATA_MASK, |
| 68 | .receiver_fn = sclp_conf_receiver_fn, |
| 69 | }; |
| 70 | |
| 71 | static int __init sclp_conf_init(void) |
| 72 | { |
| 73 | int rc; |
| 74 | |
| 75 | INIT_WORK(&sclp_cpu_capability_work, sclp_cpu_capability_notify); |
Heiko Carstens | 1e48951 | 2008-04-30 13:38:37 +0200 | [diff] [blame] | 76 | INIT_WORK(&sclp_cpu_change_work, sclp_cpu_change_notify); |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 77 | |
| 78 | rc = sclp_register(&sclp_conf_register); |
Martin Schwidefsky | a12c53f | 2008-07-14 09:59:28 +0200 | [diff] [blame] | 79 | if (rc) |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 80 | return rc; |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 81 | |
Peter Oberparleiter | d082d3c | 2008-02-19 15:29:32 +0100 | [diff] [blame] | 82 | if (!(sclp_conf_register.sclp_send_mask & EVTYP_CONFMGMDATA_MASK)) { |
Martin Schwidefsky | b3ff088 | 2008-12-25 13:39:48 +0100 | [diff] [blame] | 83 | pr_warning("no configuration management.\n"); |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 84 | sclp_unregister(&sclp_conf_register); |
| 85 | rc = -ENOSYS; |
| 86 | } |
| 87 | return rc; |
| 88 | } |
| 89 | |
| 90 | __initcall(sclp_conf_init); |