Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 1 | /* |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 2 | * Copyright IBM Corp. 2007 |
| 3 | * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com> |
| 4 | */ |
| 5 | |
Martin Schwidefsky | b3ff088 | 2008-12-25 13:39:48 +0100 | [diff] [blame] | 6 | #define KMSG_COMPONENT "sclp_config" |
| 7 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
| 8 | |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 9 | #include <linux/init.h> |
| 10 | #include <linux/errno.h> |
| 11 | #include <linux/cpu.h> |
Kay Sievers | 8a25a2f | 2011-12-21 14:29:42 -0800 | [diff] [blame] | 12 | #include <linux/device.h> |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 13 | #include <linux/workqueue.h> |
Heiko Carstens | 1e48951 | 2008-04-30 13:38:37 +0200 | [diff] [blame] | 14 | #include <asm/smp.h> |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 15 | |
Martin Schwidefsky | b3ff088 | 2008-12-25 13:39:48 +0100 | [diff] [blame] | 16 | #include "sclp.h" |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 17 | |
| 18 | struct conf_mgm_data { |
| 19 | u8 reserved; |
| 20 | u8 ev_qualifier; |
| 21 | } __attribute__((packed)); |
| 22 | |
Heiko Carstens | 1e48951 | 2008-04-30 13:38:37 +0200 | [diff] [blame] | 23 | #define EV_QUAL_CPU_CHANGE 1 |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 24 | #define EV_QUAL_CAP_CHANGE 3 |
| 25 | |
| 26 | static struct work_struct sclp_cpu_capability_work; |
Heiko Carstens | 1e48951 | 2008-04-30 13:38:37 +0200 | [diff] [blame] | 27 | static struct work_struct sclp_cpu_change_work; |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 28 | |
| 29 | static void sclp_cpu_capability_notify(struct work_struct *work) |
| 30 | { |
| 31 | int cpu; |
Kay Sievers | 8a25a2f | 2011-12-21 14:29:42 -0800 | [diff] [blame] | 32 | struct device *dev; |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 33 | |
Heiko Carstens | 8e10230 | 2011-01-05 12:48:18 +0100 | [diff] [blame] | 34 | s390_adjust_jiffies(); |
Martin Schwidefsky | b3ff088 | 2008-12-25 13:39:48 +0100 | [diff] [blame] | 35 | pr_warning("cpu capability changed.\n"); |
Gautham R Shenoy | 86ef5c9 | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 36 | get_online_cpus(); |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 37 | for_each_online_cpu(cpu) { |
Kay Sievers | 8a25a2f | 2011-12-21 14:29:42 -0800 | [diff] [blame] | 38 | dev = get_cpu_device(cpu); |
| 39 | kobject_uevent(&dev->kobj, KOBJ_CHANGE); |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 40 | } |
Gautham R Shenoy | 86ef5c9 | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 41 | put_online_cpus(); |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 42 | } |
| 43 | |
Heiko Carstens | b9732ca | 2008-07-14 09:57:28 +0200 | [diff] [blame] | 44 | static void __ref sclp_cpu_change_notify(struct work_struct *work) |
| 45 | { |
Heiko Carstens | fc7e1e4 | 2008-08-01 16:39:23 +0200 | [diff] [blame] | 46 | smp_rescan_cpus(); |
Heiko Carstens | 1e48951 | 2008-04-30 13:38:37 +0200 | [diff] [blame] | 47 | } |
| 48 | |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 49 | static void sclp_conf_receiver_fn(struct evbuf_header *evbuf) |
| 50 | { |
| 51 | struct conf_mgm_data *cdata; |
| 52 | |
| 53 | cdata = (struct conf_mgm_data *)(evbuf + 1); |
Heiko Carstens | 1e48951 | 2008-04-30 13:38:37 +0200 | [diff] [blame] | 54 | switch (cdata->ev_qualifier) { |
| 55 | case EV_QUAL_CPU_CHANGE: |
| 56 | schedule_work(&sclp_cpu_change_work); |
| 57 | break; |
| 58 | case EV_QUAL_CAP_CHANGE: |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 59 | schedule_work(&sclp_cpu_capability_work); |
Heiko Carstens | 1e48951 | 2008-04-30 13:38:37 +0200 | [diff] [blame] | 60 | break; |
| 61 | } |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | static struct sclp_register sclp_conf_register = |
| 65 | { |
| 66 | .receive_mask = EVTYP_CONFMGMDATA_MASK, |
| 67 | .receiver_fn = sclp_conf_receiver_fn, |
| 68 | }; |
| 69 | |
| 70 | static int __init sclp_conf_init(void) |
| 71 | { |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 72 | INIT_WORK(&sclp_cpu_capability_work, sclp_cpu_capability_notify); |
Heiko Carstens | 1e48951 | 2008-04-30 13:38:37 +0200 | [diff] [blame] | 73 | INIT_WORK(&sclp_cpu_change_work, sclp_cpu_change_notify); |
Heiko Carstens | 1b60f68 | 2011-05-23 10:24:37 +0200 | [diff] [blame] | 74 | return sclp_register(&sclp_conf_register); |
Heiko Carstens | 2fc2d1e | 2007-04-27 16:01:56 +0200 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | __initcall(sclp_conf_init); |