blob: 944156207477448ba0e48393212923fee2abfb16 [file] [log] [blame]
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +02001/*
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +02002 * Copyright IBM Corp. 2007
3 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
4 */
5
Martin Schwidefskyb3ff0882008-12-25 13:39:48 +01006#define KMSG_COMPONENT "sclp_config"
7#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
8
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +02009#include <linux/init.h>
10#include <linux/errno.h>
11#include <linux/cpu.h>
Kay Sievers8a25a2f2011-12-21 14:29:42 -080012#include <linux/device.h>
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020013#include <linux/workqueue.h>
Heiko Carstens1e489512008-04-30 13:38:37 +020014#include <asm/smp.h>
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020015
Martin Schwidefskyb3ff0882008-12-25 13:39:48 +010016#include "sclp.h"
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020017
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;
Kay Sievers8a25a2f2011-12-21 14:29:42 -080032 struct device *dev;
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020033
Heiko Carstens8e102302011-01-05 12:48:18 +010034 s390_adjust_jiffies();
Heiko Carstens363fd4c2013-07-26 11:03:16 +020035 pr_info("CPU capability may have changed\n");
Gautham R Shenoy86ef5c92008-01-25 21:08:02 +010036 get_online_cpus();
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020037 for_each_online_cpu(cpu) {
Kay Sievers8a25a2f2011-12-21 14:29:42 -080038 dev = get_cpu_device(cpu);
39 kobject_uevent(&dev->kobj, KOBJ_CHANGE);
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020040 }
Gautham R Shenoy86ef5c92008-01-25 21:08:02 +010041 put_online_cpus();
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020042}
43
Heiko Carstensb9732ca2008-07-14 09:57:28 +020044static void __ref sclp_cpu_change_notify(struct work_struct *work)
45{
Heiko Carstensfc7e1e42008-08-01 16:39:23 +020046 smp_rescan_cpus();
Heiko Carstens1e489512008-04-30 13:38:37 +020047}
48
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020049static 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 Carstens1e489512008-04-30 13:38:37 +020054 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 Carstens2fc2d1e2007-04-27 16:01:56 +020059 schedule_work(&sclp_cpu_capability_work);
Heiko Carstens1e489512008-04-30 13:38:37 +020060 break;
61 }
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020062}
63
64static struct sclp_register sclp_conf_register =
65{
66 .receive_mask = EVTYP_CONFMGMDATA_MASK,
67 .receiver_fn = sclp_conf_receiver_fn,
68};
69
70static int __init sclp_conf_init(void)
71{
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020072 INIT_WORK(&sclp_cpu_capability_work, sclp_cpu_capability_notify);
Heiko Carstens1e489512008-04-30 13:38:37 +020073 INIT_WORK(&sclp_cpu_change_work, sclp_cpu_change_notify);
Heiko Carstens1b60f682011-05-23 10:24:37 +020074 return sclp_register(&sclp_conf_register);
Heiko Carstens2fc2d1e2007-04-27 16:01:56 +020075}
76
77__initcall(sclp_conf_init);