Skip to content

Commit 2fc2d1e

Browse files
heicarstMartin Schwidefsky
authored andcommitted
[S390] Processor degradation notification.
Generate uevents for all cpus if cpu capability changes. This can happen e.g. because the cpus are overheating. The cpu capability can be read via /sys/devices/system/cpu/cpuN/capability. Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
1 parent db77aa5 commit 2fc2d1e

6 files changed

Lines changed: 140 additions & 6 deletions

File tree

‎arch/s390/kernel/smp.c‎

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -821,19 +821,57 @@ int setup_profiling_timer(unsigned int multiplier)
821821

822822
static DEFINE_PER_CPU(struct cpu, cpu_devices);
823823

824+
static ssize_t show_capability(struct sys_device *dev, char *buf)
825+
{
826+
unsigned int capability;
827+
int rc;
828+
829+
rc = get_cpu_capability(&capability);
830+
if (rc)
831+
return rc;
832+
return sprintf(buf, "%u\n", capability);
833+
}
834+
static SYSDEV_ATTR(capability, 0444, show_capability, NULL);
835+
836+
static int __cpuinit smp_cpu_notify(struct notifier_block *self,
837+
unsigned long action, void *hcpu)
838+
{
839+
unsigned int cpu = (unsigned int)(long)hcpu;
840+
struct cpu *c = &per_cpu(cpu_devices, cpu);
841+
struct sys_device *s = &c->sysdev;
842+
843+
switch (action) {
844+
case CPU_ONLINE:
845+
if (sysdev_create_file(s, &attr_capability))
846+
return NOTIFY_BAD;
847+
break;
848+
case CPU_DEAD:
849+
sysdev_remove_file(s, &attr_capability);
850+
break;
851+
}
852+
return NOTIFY_OK;
853+
}
854+
855+
static struct notifier_block __cpuinitdata smp_cpu_nb = {
856+
.notifier_call = smp_cpu_notify,
857+
};
858+
824859
static int __init topology_init(void)
825860
{
826861
int cpu;
827-
int ret;
862+
863+
register_cpu_notifier(&smp_cpu_nb);
828864

829865
for_each_possible_cpu(cpu) {
830866
struct cpu *c = &per_cpu(cpu_devices, cpu);
867+
struct sys_device *s = &c->sysdev;
831868

832869
c->hotpluggable = 1;
833-
ret = register_cpu(c, cpu);
834-
if (ret)
835-
printk(KERN_WARNING "topology_init: register_cpu %d "
836-
"failed (%d)\n", cpu, ret);
870+
register_cpu(c, cpu);
871+
if (!cpu_online(cpu))
872+
continue;
873+
s = &c->sysdev;
874+
sysdev_create_file(s, &attr_capability);
837875
}
838876
return 0;
839877
}

‎drivers/s390/char/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44

55
obj-y += ctrlchar.o keyboard.o defkeymap.o sclp.o sclp_rw.o sclp_quiesce.o \
6-
sclp_info.o sclp_chp.o
6+
sclp_info.o sclp_config.o sclp_chp.o
77

88
obj-$(CONFIG_TN3270) += raw3270.o
99
obj-$(CONFIG_TN3270_CONSOLE) += con3270.o

‎drivers/s390/char/sclp.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#define EVTYP_CNTLPROGIDENT 0x0B
2828
#define EVTYP_SIGQUIESCE 0x1D
2929
#define EVTYP_VT220MSG 0x1A
30+
#define EVTYP_CONFMGMDATA 0x04
3031
#define EVTYP_SDIAS 0x1C
3132

3233
#define EVTYP_OPCMD_MASK 0x80000000
@@ -37,6 +38,7 @@
3738
#define EVTYP_CTLPROGIDENT_MASK 0x00200000
3839
#define EVTYP_SIGQUIESCE_MASK 0x00000008
3940
#define EVTYP_VT220MSG_MASK 0x00000040
41+
#define EVTYP_CONFMGMDATA_MASK 0x10000000
4042
#define EVTYP_SDIAS_MASK 0x00000010
4143

4244
#define GNRLMSGFLGS_DOM 0x8000

‎drivers/s390/char/sclp_config.c‎

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
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>
13+
#include "sclp.h"
14+
15+
#define TAG "sclp_config: "
16+
17+
struct conf_mgm_data {
18+
u8 reserved;
19+
u8 ev_qualifier;
20+
} __attribute__((packed));
21+
22+
#define EV_QUAL_CAP_CHANGE 3
23+
24+
static struct work_struct sclp_cpu_capability_work;
25+
26+
static void sclp_cpu_capability_notify(struct work_struct *work)
27+
{
28+
int cpu;
29+
struct sys_device *sysdev;
30+
31+
printk(KERN_WARNING TAG "cpu capability changed.\n");
32+
lock_cpu_hotplug();
33+
for_each_online_cpu(cpu) {
34+
sysdev = get_cpu_sysdev(cpu);
35+
kobject_uevent(&sysdev->kobj, KOBJ_CHANGE);
36+
}
37+
unlock_cpu_hotplug();
38+
}
39+
40+
static void sclp_conf_receiver_fn(struct evbuf_header *evbuf)
41+
{
42+
struct conf_mgm_data *cdata;
43+
44+
cdata = (struct conf_mgm_data *)(evbuf + 1);
45+
if (cdata->ev_qualifier == EV_QUAL_CAP_CHANGE)
46+
schedule_work(&sclp_cpu_capability_work);
47+
}
48+
49+
static struct sclp_register sclp_conf_register =
50+
{
51+
.receive_mask = EVTYP_CONFMGMDATA_MASK,
52+
.receiver_fn = sclp_conf_receiver_fn,
53+
};
54+
55+
static int __init sclp_conf_init(void)
56+
{
57+
int rc;
58+
59+
INIT_WORK(&sclp_cpu_capability_work, sclp_cpu_capability_notify);
60+
61+
rc = sclp_register(&sclp_conf_register);
62+
if (rc) {
63+
printk(KERN_ERR TAG "failed to register (%d).\n", rc);
64+
return rc;
65+
}
66+
67+
if (!(sclp_conf_register.sclp_receive_mask & EVTYP_CONFMGMDATA_MASK)) {
68+
printk(KERN_WARNING TAG "no configuration management.\n");
69+
sclp_unregister(&sclp_conf_register);
70+
rc = -ENOSYS;
71+
}
72+
return rc;
73+
}
74+
75+
__initcall(sclp_conf_init);

‎drivers/s390/sysinfo.c‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,24 @@ static __init int create_proc_sysinfo(void)
357357

358358
__initcall(create_proc_sysinfo);
359359

360+
int get_cpu_capability(unsigned int *capability)
361+
{
362+
struct sysinfo_1_2_2 *info;
363+
int rc;
364+
365+
info = (void *) get_zeroed_page(GFP_KERNEL);
366+
if (!info)
367+
return -ENOMEM;
368+
rc = stsi(info, 1, 2, 2);
369+
if (rc == -ENOSYS)
370+
goto out;
371+
rc = 0;
372+
*capability = info->capability;
373+
out:
374+
free_page((unsigned long) info);
375+
return rc;
376+
}
377+
360378
/*
361379
* CPU capability might have changed. Therefore recalculate loops_per_jiffy.
362380
*/

‎include/asm-s390/processor.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ struct cpuinfo_S390
5757

5858
extern void s390_adjust_jiffies(void);
5959
extern void print_cpu_info(struct cpuinfo_S390 *);
60+
extern int get_cpu_capability(unsigned int *);
6061

6162
/* Lazy FPU handling on uni-processor */
6263
extern struct task_struct *last_task_used_math;

0 commit comments

Comments
 (0)