2 * drivers/s390/char/sclp_config.c
4 * Copyright IBM Corp. 2007
5 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
8 #include <linux/init.h>
9 #include <linux/errno.h>
10 #include <linux/cpu.h>
11 #include <linux/kthread.h>
12 #include <linux/sysdev.h>
13 #include <linux/workqueue.h>
17 #define TAG "sclp_config: "
19 struct conf_mgm_data
{
22 } __attribute__((packed
));
24 #define EV_QUAL_CPU_CHANGE 1
25 #define EV_QUAL_CAP_CHANGE 3
27 static struct work_struct sclp_cpu_capability_work
;
28 static struct work_struct sclp_cpu_change_work
;
30 static void sclp_cpu_capability_notify(struct work_struct
*work
)
33 struct sys_device
*sysdev
;
35 printk(KERN_WARNING TAG
"cpu capability changed.\n");
37 for_each_online_cpu(cpu
) {
38 sysdev
= get_cpu_sysdev(cpu
);
39 kobject_uevent(&sysdev
->kobj
, KOBJ_CHANGE
);
44 static int sclp_cpu_kthread(void *data
)
50 static void __ref
sclp_cpu_change_notify(struct work_struct
*work
)
52 /* Can't call smp_rescan_cpus() from workqueue context since it may
53 * deadlock in case of cpu hotplug. So we have to create a kernel
54 * thread in order to call it.
56 kthread_run(sclp_cpu_kthread
, NULL
, "cpu_rescan");
59 static void sclp_conf_receiver_fn(struct evbuf_header
*evbuf
)
61 struct conf_mgm_data
*cdata
;
63 cdata
= (struct conf_mgm_data
*)(evbuf
+ 1);
64 switch (cdata
->ev_qualifier
) {
65 case EV_QUAL_CPU_CHANGE
:
66 schedule_work(&sclp_cpu_change_work
);
68 case EV_QUAL_CAP_CHANGE
:
69 schedule_work(&sclp_cpu_capability_work
);
74 static struct sclp_register sclp_conf_register
=
76 .receive_mask
= EVTYP_CONFMGMDATA_MASK
,
77 .receiver_fn
= sclp_conf_receiver_fn
,
80 static int __init
sclp_conf_init(void)
84 INIT_WORK(&sclp_cpu_capability_work
, sclp_cpu_capability_notify
);
85 INIT_WORK(&sclp_cpu_change_work
, sclp_cpu_change_notify
);
87 rc
= sclp_register(&sclp_conf_register
);
91 if (!(sclp_conf_register
.sclp_send_mask
& EVTYP_CONFMGMDATA_MASK
)) {
92 printk(KERN_WARNING TAG
"no configuration management.\n");
93 sclp_unregister(&sclp_conf_register
);
99 __initcall(sclp_conf_init
);