sclp_config.c 1.94 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
/*
 *  drivers/s390/char/sclp_config.c
 *
 *    Copyright IBM Corp. 2007
 *    Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
 */

#include <linux/init.h>
#include <linux/errno.h>
#include <linux/cpu.h>
#include <linux/sysdev.h>
#include <linux/workqueue.h>
13
#include <asm/smp.h>
14 15 16 17 18 19 20 21 22
#include "sclp.h"

#define TAG	"sclp_config: "

struct conf_mgm_data {
	u8 reserved;
	u8 ev_qualifier;
} __attribute__((packed));

23
#define EV_QUAL_CPU_CHANGE	1
24 25 26
#define EV_QUAL_CAP_CHANGE	3

static struct work_struct sclp_cpu_capability_work;
27
static struct work_struct sclp_cpu_change_work;
28 29 30 31 32 33 34

static void sclp_cpu_capability_notify(struct work_struct *work)
{
	int cpu;
	struct sys_device *sysdev;

	printk(KERN_WARNING TAG "cpu capability changed.\n");
35
	get_online_cpus();
36 37 38 39
	for_each_online_cpu(cpu) {
		sysdev = get_cpu_sysdev(cpu);
		kobject_uevent(&sysdev->kobj, KOBJ_CHANGE);
	}
40
	put_online_cpus();
41 42
}

43 44 45 46 47
static void sclp_cpu_change_notify(struct work_struct *work)
{
	smp_rescan_cpus();
}

48 49 50 51 52
static void sclp_conf_receiver_fn(struct evbuf_header *evbuf)
{
	struct conf_mgm_data *cdata;

	cdata = (struct conf_mgm_data *)(evbuf + 1);
53 54 55 56 57
	switch (cdata->ev_qualifier) {
	case EV_QUAL_CPU_CHANGE:
		schedule_work(&sclp_cpu_change_work);
		break;
	case EV_QUAL_CAP_CHANGE:
58
		schedule_work(&sclp_cpu_capability_work);
59 60
		break;
	}
61 62 63 64 65 66 67 68 69 70 71 72 73
}

static struct sclp_register sclp_conf_register =
{
	.receive_mask = EVTYP_CONFMGMDATA_MASK,
	.receiver_fn  = sclp_conf_receiver_fn,
};

static int __init sclp_conf_init(void)
{
	int rc;

	INIT_WORK(&sclp_cpu_capability_work, sclp_cpu_capability_notify);
74
	INIT_WORK(&sclp_cpu_change_work, sclp_cpu_change_notify);
75 76 77 78 79 80 81

	rc = sclp_register(&sclp_conf_register);
	if (rc) {
		printk(KERN_ERR TAG "failed to register (%d).\n", rc);
		return rc;
	}

82
	if (!(sclp_conf_register.sclp_send_mask & EVTYP_CONFMGMDATA_MASK)) {
83 84 85 86 87 88 89 90
		printk(KERN_WARNING TAG "no configuration management.\n");
		sclp_unregister(&sclp_conf_register);
		rc = -ENOSYS;
	}
	return rc;
}

__initcall(sclp_conf_init);