blob: b497afe061cc4f0731fd625ca317386d5af0c85f [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
Martin Schwidefskyb3ff0882008-12-25 13:39:48 +01008#define KMSG_COMPONENT "sclp_config"
9#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
10
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020011#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 Carstens1e489512008-04-30 13:38:37 +020016#include <asm/smp.h>
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020017
Martin Schwidefskyb3ff0882008-12-25 13:39:48 +010018#include "sclp.h"
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020019
20struct conf_mgm_data {
21 u8 reserved;
22 u8 ev_qualifier;
23} __attribute__((packed));
24
Heiko Carstens1e489512008-04-30 13:38:37 +020025#define EV_QUAL_CPU_CHANGE 1
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020026#define EV_QUAL_CAP_CHANGE 3
27
28static struct work_struct sclp_cpu_capability_work;
Heiko Carstens1e489512008-04-30 13:38:37 +020029static struct work_struct sclp_cpu_change_work;
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020030
31static void sclp_cpu_capability_notify(struct work_struct *work)
32{
33 int cpu;
34 struct sys_device *sysdev;
35
Martin Schwidefskyb3ff0882008-12-25 13:39:48 +010036 pr_warning("cpu capability changed.\n");
Gautham R Shenoy86ef5c92008-01-25 21:08:02 +010037 get_online_cpus();
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020038 for_each_online_cpu(cpu) {
39 sysdev = get_cpu_sysdev(cpu);
40 kobject_uevent(&sysdev->kobj, KOBJ_CHANGE);
41 }
Gautham R Shenoy86ef5c92008-01-25 21:08:02 +010042 put_online_cpus();
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020043}
44
Heiko Carstensb9732ca2008-07-14 09:57:28 +020045static void __ref sclp_cpu_change_notify(struct work_struct *work)
46{
Heiko Carstensfc7e1e42008-08-01 16:39:23 +020047 smp_rescan_cpus();
Heiko Carstens1e489512008-04-30 13:38:37 +020048}
49
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020050static 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 Carstens1e489512008-04-30 13:38:37 +020055 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 Carstens2fc2d1e2007-04-27 16:01:56 +020060 schedule_work(&sclp_cpu_capability_work);
Heiko Carstens1e489512008-04-30 13:38:37 +020061 break;
62 }
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020063}
64
65static struct sclp_register sclp_conf_register =
66{
67 .receive_mask = EVTYP_CONFMGMDATA_MASK,
68 .receiver_fn = sclp_conf_receiver_fn,
69};
70
71static int __init sclp_conf_init(void)
72{
73 int rc;
74
75 INIT_WORK(&sclp_cpu_capability_work, sclp_cpu_capability_notify);
Heiko Carstens1e489512008-04-30 13:38:37 +020076 INIT_WORK(&sclp_cpu_change_work, sclp_cpu_change_notify);
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020077
78 rc = sclp_register(&sclp_conf_register);
Martin Schwidefskya12c53f2008-07-14 09:59:28 +020079 if (rc)
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020080 return rc;
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020081
Peter Oberparleiterd082d3c2008-02-19 15:29:32 +010082 if (!(sclp_conf_register.sclp_send_mask & EVTYP_CONFMGMDATA_MASK)) {
Martin Schwidefskyb3ff0882008-12-25 13:39:48 +010083 pr_warning("no configuration management.\n");
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020084 sclp_unregister(&sclp_conf_register);
85 rc = -ENOSYS;
86 }
87 return rc;
88}
89
90__initcall(sclp_conf_init);