blob: 3c03c1060be6d3cb12c408c7834936f651050def [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>
Kay Sievers8a25a2f2011-12-21 14:29:42 -080014#include <linux/device.h>
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020015#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;
Kay Sievers8a25a2f2011-12-21 14:29:42 -080034 struct device *dev;
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020035
Heiko Carstens8e102302011-01-05 12:48:18 +010036 s390_adjust_jiffies();
Martin Schwidefskyb3ff0882008-12-25 13:39:48 +010037 pr_warning("cpu capability changed.\n");
Gautham R Shenoy86ef5c92008-01-25 21:08:02 +010038 get_online_cpus();
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020039 for_each_online_cpu(cpu) {
Kay Sievers8a25a2f2011-12-21 14:29:42 -080040 dev = get_cpu_device(cpu);
41 kobject_uevent(&dev->kobj, KOBJ_CHANGE);
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020042 }
Gautham R Shenoy86ef5c92008-01-25 21:08:02 +010043 put_online_cpus();
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020044}
45
Heiko Carstensb9732ca2008-07-14 09:57:28 +020046static void __ref sclp_cpu_change_notify(struct work_struct *work)
47{
Heiko Carstensfc7e1e42008-08-01 16:39:23 +020048 smp_rescan_cpus();
Heiko Carstens1e489512008-04-30 13:38:37 +020049}
50
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020051static void sclp_conf_receiver_fn(struct evbuf_header *evbuf)
52{
53 struct conf_mgm_data *cdata;
54
55 cdata = (struct conf_mgm_data *)(evbuf + 1);
Heiko Carstens1e489512008-04-30 13:38:37 +020056 switch (cdata->ev_qualifier) {
57 case EV_QUAL_CPU_CHANGE:
58 schedule_work(&sclp_cpu_change_work);
59 break;
60 case EV_QUAL_CAP_CHANGE:
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020061 schedule_work(&sclp_cpu_capability_work);
Heiko Carstens1e489512008-04-30 13:38:37 +020062 break;
63 }
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020064}
65
66static struct sclp_register sclp_conf_register =
67{
68 .receive_mask = EVTYP_CONFMGMDATA_MASK,
69 .receiver_fn = sclp_conf_receiver_fn,
70};
71
72static int __init sclp_conf_init(void)
73{
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020074 INIT_WORK(&sclp_cpu_capability_work, sclp_cpu_capability_notify);
Heiko Carstens1e489512008-04-30 13:38:37 +020075 INIT_WORK(&sclp_cpu_change_work, sclp_cpu_change_notify);
Heiko Carstens1b60f682011-05-23 10:24:37 +020076 return sclp_register(&sclp_conf_register);
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020077}
78
79__initcall(sclp_conf_init);