blob: 9e784d5f7f576460b69324361801bb9e749f81be [file] [log] [blame]
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +02001/*
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
8#include <linux/init.h>
9#include <linux/errno.h>
10#include <linux/cpu.h>
11#include <linux/sysdev.h>
12#include <linux/workqueue.h>
Heiko Carstens1e489512008-04-30 13:38:37 +020013#include <asm/smp.h>
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020014#include "sclp.h"
15
16#define TAG "sclp_config: "
17
18struct conf_mgm_data {
19 u8 reserved;
20 u8 ev_qualifier;
21} __attribute__((packed));
22
Heiko Carstens1e489512008-04-30 13:38:37 +020023#define EV_QUAL_CPU_CHANGE 1
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020024#define EV_QUAL_CAP_CHANGE 3
25
26static struct work_struct sclp_cpu_capability_work;
Heiko Carstens1e489512008-04-30 13:38:37 +020027static struct work_struct sclp_cpu_change_work;
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020028
29static void sclp_cpu_capability_notify(struct work_struct *work)
30{
31 int cpu;
32 struct sys_device *sysdev;
33
34 printk(KERN_WARNING TAG "cpu capability changed.\n");
Gautham R Shenoy86ef5c92008-01-25 21:08:02 +010035 get_online_cpus();
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020036 for_each_online_cpu(cpu) {
37 sysdev = get_cpu_sysdev(cpu);
38 kobject_uevent(&sysdev->kobj, KOBJ_CHANGE);
39 }
Gautham R Shenoy86ef5c92008-01-25 21:08:02 +010040 put_online_cpus();
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020041}
42
Heiko Carstens1e489512008-04-30 13:38:37 +020043static void sclp_cpu_change_notify(struct work_struct *work)
44{
45 smp_rescan_cpus();
46}
47
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020048static void sclp_conf_receiver_fn(struct evbuf_header *evbuf)
49{
50 struct conf_mgm_data *cdata;
51
52 cdata = (struct conf_mgm_data *)(evbuf + 1);
Heiko Carstens1e489512008-04-30 13:38:37 +020053 switch (cdata->ev_qualifier) {
54 case EV_QUAL_CPU_CHANGE:
55 schedule_work(&sclp_cpu_change_work);
56 break;
57 case EV_QUAL_CAP_CHANGE:
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020058 schedule_work(&sclp_cpu_capability_work);
Heiko Carstens1e489512008-04-30 13:38:37 +020059 break;
60 }
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020061}
62
63static struct sclp_register sclp_conf_register =
64{
65 .receive_mask = EVTYP_CONFMGMDATA_MASK,
66 .receiver_fn = sclp_conf_receiver_fn,
67};
68
69static int __init sclp_conf_init(void)
70{
71 int rc;
72
73 INIT_WORK(&sclp_cpu_capability_work, sclp_cpu_capability_notify);
Heiko Carstens1e489512008-04-30 13:38:37 +020074 INIT_WORK(&sclp_cpu_change_work, sclp_cpu_change_notify);
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020075
76 rc = sclp_register(&sclp_conf_register);
77 if (rc) {
78 printk(KERN_ERR TAG "failed to register (%d).\n", rc);
79 return rc;
80 }
81
Peter Oberparleiterd082d3c2008-02-19 15:29:32 +010082 if (!(sclp_conf_register.sclp_send_mask & EVTYP_CONFMGMDATA_MASK)) {
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020083 printk(KERN_WARNING TAG "no configuration management.\n");
84 sclp_unregister(&sclp_conf_register);
85 rc = -ENOSYS;
86 }
87 return rc;
88}
89
90__initcall(sclp_conf_init);