aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Oberparleiter <peter.oberparleiter@de.ibm.com>2007-04-27 10:01:28 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2007-04-27 10:01:38 -0400
commite6b6e10ac1de116fc6d2288f185393014851cccf (patch)
tree85602cd6aed77d36cf87cbc05ac380c568e757ac
parentd120b2a4e60cc9e62e7cc5dcf049100af3745cc4 (diff)
[S390] cio: Introduce separate files for channel-path related code.
Signed-off-by: Peter Oberparleiter <peter.oberparleiter@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
-rw-r--r--drivers/s390/cio/Makefile2
-rw-r--r--drivers/s390/cio/chp.c433
-rw-r--r--drivers/s390/cio/chp.h37
-rw-r--r--drivers/s390/cio/chsc.c473
-rw-r--r--drivers/s390/cio/chsc.h28
-rw-r--r--drivers/s390/cio/cio.c8
-rw-r--r--drivers/s390/cio/css.h1
-rw-r--r--drivers/s390/cio/device_fsm.c6
-rw-r--r--drivers/s390/cio/device_ops.c7
-rw-r--r--drivers/s390/s390mach.c1
10 files changed, 534 insertions, 462 deletions
diff --git a/drivers/s390/cio/Makefile b/drivers/s390/cio/Makefile
index c490c2a1c2fc..fe7b3ffa1eaa 100644
--- a/drivers/s390/cio/Makefile
+++ b/drivers/s390/cio/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the S/390 common i/o drivers 2# Makefile for the S/390 common i/o drivers
3# 3#
4 4
5obj-y += airq.o blacklist.o chsc.o cio.o css.o 5obj-y += airq.o blacklist.o chsc.o cio.o css.o chp.o
6ccw_device-objs += device.o device_fsm.o device_ops.o 6ccw_device-objs += device.o device_fsm.o device_ops.o
7ccw_device-objs += device_id.o device_pgid.o device_status.o 7ccw_device-objs += device_id.o device_pgid.o device_status.o
8obj-y += ccw_device.o cmf.o 8obj-y += ccw_device.o cmf.o
diff --git a/drivers/s390/cio/chp.c b/drivers/s390/cio/chp.c
new file mode 100644
index 000000000000..6e04521accd8
--- /dev/null
+++ b/drivers/s390/cio/chp.c
@@ -0,0 +1,433 @@
1/*
2 * drivers/s390/cio/chp.c
3 *
4 * Copyright IBM Corp. 1999,2007
5 * Author(s): Cornelia Huck (cornelia.huck@de.ibm.com)
6 * Arnd Bergmann (arndb@de.ibm.com)
7 * Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
8 */
9
10#include <linux/bug.h>
11#include <linux/workqueue.h>
12#include <linux/spinlock.h>
13#include <asm/errno.h>
14
15#include "chpid.h"
16#include "cio.h"
17#include "css.h"
18#include "ioasm.h"
19#include "cio_debug.h"
20#include "chp.h"
21
22#define to_channelpath(device) container_of(device, struct channel_path, dev)
23
24/* Return channel_path struct for given chpid. */
25static inline struct channel_path *chpid_to_chp(struct chp_id chpid)
26{
27 return css[chpid.cssid]->chps[chpid.id];
28}
29
30/* Set vary state for given chpid. */
31static void set_chp_logically_online(struct chp_id chpid, int onoff)
32{
33 chpid_to_chp(chpid)->state = onoff;
34}
35
36/* On succes return 0 if channel-path is varied offline, 1 if it is varied
37 * online. Return -ENODEV if channel-path is not registered. */
38int chp_get_status(struct chp_id chpid)
39{
40 return (chpid_to_chp(chpid) ? chpid_to_chp(chpid)->state : -ENODEV);
41}
42
43/**
44 * chp_get_sch_opm - return opm for subchannel
45 * @sch: subchannel
46 *
47 * Calculate and return the operational path mask (opm) based on the chpids
48 * used by the subchannel and the status of the associated channel-paths.
49 */
50u8 chp_get_sch_opm(struct subchannel *sch)
51{
52 struct chp_id chpid;
53 int opm;
54 int i;
55
56 opm = 0;
57 chp_id_init(&chpid);
58 for (i=0; i < 8; i++) {
59 opm <<= 1;
60 chpid.id = sch->schib.pmcw.chpid[i];
61 if (chp_get_status(chpid) != 0)
62 opm |= 1;
63 }
64 return opm;
65}
66
67/**
68 * chp_is_registered - check if a channel-path is registered
69 * @chpid: channel-path ID
70 *
71 * Return non-zero if a channel-path with the given chpid is registered,
72 * zero otherwise.
73 */
74int chp_is_registered(struct chp_id chpid)
75{
76 return chpid_to_chp(chpid) != NULL;
77}
78
79/*
80 * Function: s390_vary_chpid
81 * Varies the specified chpid online or offline
82 */
83static int s390_vary_chpid(struct chp_id chpid, int on)
84{
85 char dbf_text[15];
86 int status;
87
88 sprintf(dbf_text, on?"varyon%x.%02x":"varyoff%x.%02x", chpid.cssid,
89 chpid.id);
90 CIO_TRACE_EVENT( 2, dbf_text);
91
92 status = chp_get_status(chpid);
93 if (status < 0) {
94 printk(KERN_ERR "Can't vary unknown chpid %x.%02x\n",
95 chpid.cssid, chpid.id);
96 return -EINVAL;
97 }
98
99 if (!on && !status) {
100 printk(KERN_ERR "chpid %x.%02x is already offline\n",
101 chpid.cssid, chpid.id);
102 return -EINVAL;
103 }
104
105 set_chp_logically_online(chpid, on);
106 chsc_chp_vary(chpid, on);
107 return 0;
108}
109
110/*
111 * Channel measurement related functions
112 */
113static ssize_t chp_measurement_chars_read(struct kobject *kobj, char *buf,
114 loff_t off, size_t count)
115{
116 struct channel_path *chp;
117 unsigned int size;
118
119 chp = to_channelpath(container_of(kobj, struct device, kobj));
120 if (!chp->cmg_chars)
121 return 0;
122
123 size = sizeof(struct cmg_chars);
124
125 if (off > size)
126 return 0;
127 if (off + count > size)
128 count = size - off;
129 memcpy(buf, chp->cmg_chars + off, count);
130 return count;
131}
132
133static struct bin_attribute chp_measurement_chars_attr = {
134 .attr = {
135 .name = "measurement_chars",
136 .mode = S_IRUSR,
137 .owner = THIS_MODULE,
138 },
139 .size = sizeof(struct cmg_chars),
140 .read = chp_measurement_chars_read,
141};
142
143static void chp_measurement_copy_block(struct cmg_entry *buf,
144 struct channel_subsystem *css,
145 struct chp_id chpid)
146{
147 void *area;
148 struct cmg_entry *entry, reference_buf;
149 int idx;
150
151 if (chpid.id < 128) {
152 area = css->cub_addr1;
153 idx = chpid.id;
154 } else {
155 area = css->cub_addr2;
156 idx = chpid.id - 128;
157 }
158 entry = area + (idx * sizeof(struct cmg_entry));
159 do {
160 memcpy(buf, entry, sizeof(*entry));
161 memcpy(&reference_buf, entry, sizeof(*entry));
162 } while (reference_buf.values[0] != buf->values[0]);
163}
164
165static ssize_t chp_measurement_read(struct kobject *kobj, char *buf,
166 loff_t off, size_t count)
167{
168 struct channel_path *chp;
169 struct channel_subsystem *css;
170 unsigned int size;
171
172 chp = to_channelpath(container_of(kobj, struct device, kobj));
173 css = to_css(chp->dev.parent);
174
175 size = sizeof(struct cmg_entry);
176
177 /* Only allow single reads. */
178 if (off || count < size)
179 return 0;
180 chp_measurement_copy_block((struct cmg_entry *)buf, css, chp->chpid);
181 count = size;
182 return count;
183}
184
185static struct bin_attribute chp_measurement_attr = {
186 .attr = {
187 .name = "measurement",
188 .mode = S_IRUSR,
189 .owner = THIS_MODULE,
190 },
191 .size = sizeof(struct cmg_entry),
192 .read = chp_measurement_read,
193};
194
195void chp_remove_cmg_attr(struct channel_path *chp)
196{
197 device_remove_bin_file(&chp->dev, &chp_measurement_chars_attr);
198 device_remove_bin_file(&chp->dev, &chp_measurement_attr);
199}
200
201int chp_add_cmg_attr(struct channel_path *chp)
202{
203 int ret;
204
205 ret = device_create_bin_file(&chp->dev, &chp_measurement_chars_attr);
206 if (ret)
207 return ret;
208 ret = device_create_bin_file(&chp->dev, &chp_measurement_attr);
209 if (ret)
210 device_remove_bin_file(&chp->dev, &chp_measurement_chars_attr);
211 return ret;
212}
213
214/*
215 * Files for the channel path entries.
216 */
217static ssize_t chp_status_show(struct device *dev,
218 struct device_attribute *attr, char *buf)
219{
220 struct channel_path *chp = container_of(dev, struct channel_path, dev);
221
222 if (!chp)
223 return 0;
224 return (chp_get_status(chp->chpid) ? sprintf(buf, "online\n") :
225 sprintf(buf, "offline\n"));
226}
227
228static ssize_t chp_status_write(struct device *dev,
229 struct device_attribute *attr,
230 const char *buf, size_t count)
231{
232 struct channel_path *cp = container_of(dev, struct channel_path, dev);
233 char cmd[10];
234 int num_args;
235 int error;
236
237 num_args = sscanf(buf, "%5s", cmd);
238 if (!num_args)
239 return count;
240
241 if (!strnicmp(cmd, "on", 2) || !strcmp(cmd, "1"))
242 error = s390_vary_chpid(cp->chpid, 1);
243 else if (!strnicmp(cmd, "off", 3) || !strcmp(cmd, "0"))
244 error = s390_vary_chpid(cp->chpid, 0);
245 else
246 error = -EINVAL;
247
248 return error < 0 ? error : count;
249
250}
251
252static DEVICE_ATTR(status, 0644, chp_status_show, chp_status_write);
253
254static ssize_t chp_type_show(struct device *dev, struct device_attribute *attr,
255 char *buf)
256{
257 struct channel_path *chp = container_of(dev, struct channel_path, dev);
258
259 if (!chp)
260 return 0;
261 return sprintf(buf, "%x\n", chp->desc.desc);
262}
263
264static DEVICE_ATTR(type, 0444, chp_type_show, NULL);
265
266static ssize_t chp_cmg_show(struct device *dev, struct device_attribute *attr,
267 char *buf)
268{
269 struct channel_path *chp = to_channelpath(dev);
270
271 if (!chp)
272 return 0;
273 if (chp->cmg == -1) /* channel measurements not available */
274 return sprintf(buf, "unknown\n");
275 return sprintf(buf, "%x\n", chp->cmg);
276}
277
278static DEVICE_ATTR(cmg, 0444, chp_cmg_show, NULL);
279
280static ssize_t chp_shared_show(struct device *dev,
281 struct device_attribute *attr, char *buf)
282{
283 struct channel_path *chp = to_channelpath(dev);
284
285 if (!chp)
286 return 0;
287 if (chp->shared == -1) /* channel measurements not available */
288 return sprintf(buf, "unknown\n");
289 return sprintf(buf, "%x\n", chp->shared);
290}
291
292static DEVICE_ATTR(shared, 0444, chp_shared_show, NULL);
293
294static struct attribute * chp_attrs[] = {
295 &dev_attr_status.attr,
296 &dev_attr_type.attr,
297 &dev_attr_cmg.attr,
298 &dev_attr_shared.attr,
299 NULL,
300};
301
302static struct attribute_group chp_attr_group = {
303 .attrs = chp_attrs,
304};
305
306static void chp_release(struct device *dev)
307{
308 struct channel_path *cp;
309
310 cp = container_of(dev, struct channel_path, dev);
311 kfree(cp);
312}
313
314/**
315 * chp_new - register a new channel-path
316 * @chpid - channel-path ID
317 *
318 * Create and register data structure representing new channel-path. Return
319 * zero on success, non-zero otherwise.
320 */
321int chp_new(struct chp_id chpid)
322{
323 struct channel_path *chp;
324 int ret;
325
326 chp = kzalloc(sizeof(struct channel_path), GFP_KERNEL);
327 if (!chp)
328 return -ENOMEM;
329
330 /* fill in status, etc. */
331 chp->chpid = chpid;
332 chp->state = 1;
333 chp->dev.parent = &css[chpid.cssid]->device;
334 chp->dev.release = chp_release;
335 snprintf(chp->dev.bus_id, BUS_ID_SIZE, "chp%x.%02x", chpid.cssid,
336 chpid.id);
337
338 /* Obtain channel path description and fill it in. */
339 ret = chsc_determine_channel_path_description(chpid, &chp->desc);
340 if (ret)
341 goto out_free;
342 /* Get channel-measurement characteristics. */
343 if (css_characteristics_avail && css_chsc_characteristics.scmc
344 && css_chsc_characteristics.secm) {
345 ret = chsc_get_channel_measurement_chars(chp);
346 if (ret)
347 goto out_free;
348 } else {
349 static int msg_done;
350
351 if (!msg_done) {
352 printk(KERN_WARNING "cio: Channel measurements not "
353 "available, continuing.\n");
354 msg_done = 1;
355 }
356 chp->cmg = -1;
357 }
358
359 /* make it known to the system */
360 ret = device_register(&chp->dev);
361 if (ret) {
362 printk(KERN_WARNING "%s: could not register %x.%02x\n",
363 __func__, chpid.cssid, chpid.id);
364 goto out_free;
365 }
366 ret = sysfs_create_group(&chp->dev.kobj, &chp_attr_group);
367 if (ret) {
368 device_unregister(&chp->dev);
369 goto out_free;
370 }
371 mutex_lock(&css[chpid.cssid]->mutex);
372 if (css[chpid.cssid]->cm_enabled) {
373 ret = chp_add_cmg_attr(chp);
374 if (ret) {
375 sysfs_remove_group(&chp->dev.kobj, &chp_attr_group);
376 device_unregister(&chp->dev);
377 mutex_unlock(&css[chpid.cssid]->mutex);
378 goto out_free;
379 }
380 }
381 css[chpid.cssid]->chps[chpid.id] = chp;
382 mutex_unlock(&css[chpid.cssid]->mutex);
383 return ret;
384out_free:
385 kfree(chp);
386 return ret;
387}
388
389/**
390 * chp_get_chp_desc - return newly allocated channel-path description
391 * @chpid: channel-path ID
392 *
393 * On success return a newly allocated copy of the channel-path description
394 * data associated with the given channel-path ID. Return %NULL on error.
395 */
396void *chp_get_chp_desc(struct chp_id chpid)
397{
398 struct channel_path *chp;
399 struct channel_path_desc *desc;
400
401 chp = chpid_to_chp(chpid);
402 if (!chp)
403 return NULL;
404 desc = kmalloc(sizeof(struct channel_path_desc), GFP_KERNEL);
405 if (!desc)
406 return NULL;
407 memcpy(desc, &chp->desc, sizeof(struct channel_path_desc));
408 return desc;
409}
410
411/**
412 * chp_process_crw - process channel-path status change
413 * @id: channel-path ID number
414 * @status: non-zero if channel-path has become available, zero otherwise
415 *
416 * Handle channel-report-words indicating that the status of a channel-path
417 * has changed.
418 */
419int chp_process_crw(int id, int status)
420{
421 struct chp_id chpid;
422
423 chp_id_init(&chpid);
424 chpid.id = id;
425 if (status) {
426 if (!chp_is_registered(chpid))
427 chp_new(chpid);
428 return chsc_chp_online(chpid);
429 } else {
430 chsc_chp_offline(chpid);
431 return 0;
432 }
433}
diff --git a/drivers/s390/cio/chp.h b/drivers/s390/cio/chp.h
new file mode 100644
index 000000000000..ac2b1a9c3bc2
--- /dev/null
+++ b/drivers/s390/cio/chp.h
@@ -0,0 +1,37 @@
1/*
2 * drivers/s390/cio/chp.h
3 *
4 * Copyright IBM Corp. 2007
5 * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
6 */
7
8#ifndef S390_CHP_H
9#define S390_CHP_H S390_CHP_H
10
11#include <linux/types.h>
12#include <linux/device.h>
13
14#include "chpid.h"
15#include "chsc.h"
16
17struct channel_path {
18 struct chp_id chpid;
19 int state;
20 struct channel_path_desc desc;
21 /* Channel-measurement related stuff: */
22 int cmg;
23 int shared;
24 void *cmg_chars;
25 struct device dev;
26};
27
28int chp_get_status(struct chp_id chpid);
29u8 chp_get_sch_opm(struct subchannel *sch);
30int chp_is_registered(struct chp_id chpid);
31void *chp_get_chp_desc(struct chp_id chpid);
32int chp_process_crw(int id, int available);
33void chp_remove_cmg_attr(struct channel_path *chp);
34int chp_add_cmg_attr(struct channel_path *chp);
35int chp_new(struct chp_id chpid);
36
37#endif /* S390_CHP_H */
diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c
index b329851f7b55..d99f525eac08 100644
--- a/drivers/s390/cio/chsc.c
+++ b/drivers/s390/cio/chsc.c
@@ -21,54 +21,11 @@
21#include "cio_debug.h" 21#include "cio_debug.h"
22#include "ioasm.h" 22#include "ioasm.h"
23#include "chpid.h" 23#include "chpid.h"
24#include "chp.h"
24#include "chsc.h" 25#include "chsc.h"
25 26
26static void *sei_page; 27static void *sei_page;
27 28
28static int new_channel_path(struct chp_id chpid);
29
30static inline struct channel_path *chpid_to_chp(struct chp_id chpid)
31{
32 return css[chpid.cssid]->chps[chpid.id];
33}
34
35static void set_chp_logically_online(struct chp_id chpid, int onoff)
36{
37 chpid_to_chp(chpid)->state = onoff;
38}
39
40static int get_chp_status(struct chp_id chpid)
41{
42 return (chpid_to_chp(chpid) ? chpid_to_chp(chpid)->state : -ENODEV);
43}
44
45void chsc_validate_chpids(struct subchannel *sch)
46{
47 int mask, chp;
48 struct chp_id chpid;
49
50 chp_id_init(&chpid);
51 for (chp = 0; chp <= 7; chp++) {
52 mask = 0x80 >> chp;
53 chpid.id = sch->schib.pmcw.chpid[chp];
54 if (!get_chp_status(chpid))
55 /* disable using this path */
56 sch->opm &= ~mask;
57 }
58}
59
60void chpid_is_actually_online(struct chp_id chpid)
61{
62 int state;
63
64 state = get_chp_status(chpid);
65 if (state < 0) {
66 need_rescan = 1;
67 queue_work(slow_path_wq, &slow_path_work);
68 } else
69 WARN_ON(!state);
70}
71
72/* FIXME: this is _always_ called for every subchannel. shouldn't we 29/* FIXME: this is _always_ called for every subchannel. shouldn't we
73 * process more than one at a time? */ 30 * process more than one at a time? */
74static int 31static int
@@ -214,8 +171,8 @@ css_get_ssd_info(struct subchannel *sch)
214 mask = 0x80 >> j; 171 mask = 0x80 >> j;
215 chpid.id = sch->ssd_info.chpid[j]; 172 chpid.id = sch->ssd_info.chpid[j];
216 if ((sch->schib.pmcw.pim & mask) && 173 if ((sch->schib.pmcw.pim & mask) &&
217 (get_chp_status(chpid) < 0)) 174 !chp_is_registered(chpid))
218 new_channel_path(chpid); 175 chp_new(chpid);
219 } 176 }
220 } 177 }
221 return ret; 178 return ret;
@@ -227,7 +184,7 @@ s390_subchannel_remove_chpid(struct device *dev, void *data)
227 int j; 184 int j;
228 int mask; 185 int mask;
229 struct subchannel *sch; 186 struct subchannel *sch;
230 struct channel_path *chpid; 187 struct chp_id *chpid;
231 struct schib schib; 188 struct schib schib;
232 189
233 sch = to_subchannel(dev); 190 sch = to_subchannel(dev);
@@ -235,7 +192,7 @@ s390_subchannel_remove_chpid(struct device *dev, void *data)
235 for (j = 0; j < 8; j++) { 192 for (j = 0; j < 8; j++) {
236 mask = 0x80 >> j; 193 mask = 0x80 >> j;
237 if ((sch->schib.pmcw.pim & mask) && 194 if ((sch->schib.pmcw.pim & mask) &&
238 (sch->schib.pmcw.chpid[j] == chpid->chpid.id)) 195 (sch->schib.pmcw.chpid[j] == chpid->id))
239 break; 196 break;
240 } 197 }
241 if (j >= 8) 198 if (j >= 8)
@@ -285,51 +242,48 @@ out_unreg:
285 return 0; 242 return 0;
286} 243}
287 244
288static void s390_set_chpid_offline(struct chp_id chpid) 245void chsc_chp_offline(struct chp_id chpid)
289{ 246{
290 char dbf_txt[15]; 247 char dbf_txt[15];
291 struct device *dev;
292 248
293 sprintf(dbf_txt, "chpr%x.%02x", chpid.cssid, chpid.id); 249 sprintf(dbf_txt, "chpr%x.%02x", chpid.cssid, chpid.id);
294 CIO_TRACE_EVENT(2, dbf_txt); 250 CIO_TRACE_EVENT(2, dbf_txt);
295 251
296 if (get_chp_status(chpid) <= 0) 252 if (chp_get_status(chpid) <= 0)
297 return; 253 return;
298 dev = get_device(&(chpid_to_chp(chpid)->dev)); 254 bus_for_each_dev(&css_bus_type, NULL, &chpid,
299 bus_for_each_dev(&css_bus_type, NULL, to_channelpath(dev),
300 s390_subchannel_remove_chpid); 255 s390_subchannel_remove_chpid);
301 256
302 if (need_rescan || css_slow_subchannels_exist()) 257 if (need_rescan || css_slow_subchannels_exist())
303 queue_work(slow_path_wq, &slow_path_work); 258 queue_work(slow_path_wq, &slow_path_work);
304 put_device(dev);
305} 259}
306 260
307struct res_acc_data { 261struct res_acc_data {
308 struct channel_path *chp; 262 struct chp_id chpid;
309 u32 fla_mask; 263 u32 fla_mask;
310 u16 fla; 264 u16 fla;
311}; 265};
312 266
313static int 267static int s390_process_res_acc_sch(struct res_acc_data *res_data,
314s390_process_res_acc_sch(struct res_acc_data *res_data, struct subchannel *sch) 268 struct subchannel *sch)
315{ 269{
316 int found; 270 int found;
317 int chp; 271 int chp;
318 int ccode; 272 int ccode;
319 273
320 found = 0; 274 found = 0;
321 for (chp = 0; chp <= 7; chp++) 275 for (chp = 0; chp <= 7; chp++)
322 /* 276 /*
323 * check if chpid is in information updated by ssd 277 * check if chpid is in information updated by ssd
324 */ 278 */
325 if (sch->ssd_info.valid && 279 if (sch->ssd_info.valid &&
326 sch->ssd_info.chpid[chp] == res_data->chp->chpid.id && 280 sch->ssd_info.chpid[chp] == res_data->chpid.id &&
327 (sch->ssd_info.fla[chp] & res_data->fla_mask) 281 (sch->ssd_info.fla[chp] & res_data->fla_mask)
328 == res_data->fla) { 282 == res_data->fla) {
329 found = 1; 283 found = 1;
330 break; 284 break;
331 } 285 }
332 286
333 if (found == 0) 287 if (found == 0)
334 return 0; 288 return 0;
335 289
@@ -416,8 +370,8 @@ s390_process_res_acc (struct res_acc_data *res_data)
416 int rc; 370 int rc;
417 char dbf_txt[15]; 371 char dbf_txt[15];
418 372
419 sprintf(dbf_txt, "accpr%x.%02x", res_data->chp->chpid.cssid, 373 sprintf(dbf_txt, "accpr%x.%02x", res_data->chpid.cssid,
420 res_data->chp->chpid.id); 374 res_data->chpid.id);
421 CIO_TRACE_EVENT( 2, dbf_txt); 375 CIO_TRACE_EVENT( 2, dbf_txt);
422 if (res_data->fla != 0) { 376 if (res_data->fla != 0) {
423 sprintf(dbf_txt, "fla%x", res_data->fla); 377 sprintf(dbf_txt, "fla%x", res_data->fla);
@@ -503,7 +457,7 @@ static int chsc_process_sei_link_incident(struct chsc_sei_area *sei_area)
503 else { 457 else {
504 chp_id_init(&chpid); 458 chp_id_init(&chpid);
505 chpid.id = id; 459 chpid.id = id;
506 s390_set_chpid_offline(chpid); 460 chsc_chp_offline(chpid);
507 } 461 }
508 462
509 return 0; 463 return 0;
@@ -512,7 +466,6 @@ static int chsc_process_sei_link_incident(struct chsc_sei_area *sei_area)
512static int chsc_process_sei_res_acc(struct chsc_sei_area *sei_area) 466static int chsc_process_sei_res_acc(struct chsc_sei_area *sei_area)
513{ 467{
514 struct res_acc_data res_data; 468 struct res_acc_data res_data;
515 struct device *dev;
516 struct chp_id chpid; 469 struct chp_id chpid;
517 int status; 470 int status;
518 int rc; 471 int rc;
@@ -524,14 +477,13 @@ static int chsc_process_sei_res_acc(struct chsc_sei_area *sei_area)
524 chp_id_init(&chpid); 477 chp_id_init(&chpid);
525 chpid.id = sei_area->rsid; 478 chpid.id = sei_area->rsid;
526 /* allocate a new channel path structure, if needed */ 479 /* allocate a new channel path structure, if needed */
527 status = get_chp_status(chpid); 480 status = chp_get_status(chpid);
528 if (status < 0) 481 if (status < 0)
529 new_channel_path(chpid); 482 chp_new(chpid);
530 else if (!status) 483 else if (!status)
531 return 0; 484 return 0;
532 dev = get_device(&(chpid_to_chp(chpid)->dev));
533 memset(&res_data, 0, sizeof(struct res_acc_data)); 485 memset(&res_data, 0, sizeof(struct res_acc_data));
534 res_data.chp = to_channelpath(dev); 486 res_data.chpid = chpid;
535 if ((sei_area->vf & 0xc0) != 0) { 487 if ((sei_area->vf & 0xc0) != 0) {
536 res_data.fla = sei_area->fla; 488 res_data.fla = sei_area->fla;
537 if ((sei_area->vf & 0xc0) == 0xc0) 489 if ((sei_area->vf & 0xc0) == 0xc0)
@@ -542,7 +494,6 @@ static int chsc_process_sei_res_acc(struct chsc_sei_area *sei_area)
542 res_data.fla_mask = 0xff00; 494 res_data.fla_mask = 0xff00;
543 } 495 }
544 rc = s390_process_res_acc(&res_data); 496 rc = s390_process_res_acc(&res_data);
545 put_device(dev);
546 497
547 return rc; 498 return rc;
548} 499}
@@ -634,10 +585,10 @@ static int
634__chp_add(struct subchannel_id schid, void *data) 585__chp_add(struct subchannel_id schid, void *data)
635{ 586{
636 int i, mask; 587 int i, mask;
637 struct channel_path *chp; 588 struct chp_id *chpid;
638 struct subchannel *sch; 589 struct subchannel *sch;
639 590
640 chp = data; 591 chpid = data;
641 sch = get_subchannel_by_schid(schid); 592 sch = get_subchannel_by_schid(schid);
642 if (!sch) 593 if (!sch)
643 /* Check if the subchannel is now available. */ 594 /* Check if the subchannel is now available. */
@@ -646,7 +597,7 @@ __chp_add(struct subchannel_id schid, void *data)
646 for (i=0; i<8; i++) { 597 for (i=0; i<8; i++) {
647 mask = 0x80 >> i; 598 mask = 0x80 >> i;
648 if ((sch->schib.pmcw.pim & mask) && 599 if ((sch->schib.pmcw.pim & mask) &&
649 (sch->schib.pmcw.chpid[i] == chp->chpid.id)) { 600 (sch->schib.pmcw.chpid[i] == chpid->id)) {
650 if (stsch(sch->schid, &sch->schib) != 0) { 601 if (stsch(sch->schid, &sch->schib) != 0) {
651 /* Endgame. */ 602 /* Endgame. */
652 spin_unlock_irq(sch->lock); 603 spin_unlock_irq(sch->lock);
@@ -672,52 +623,24 @@ __chp_add(struct subchannel_id schid, void *data)
672 return 0; 623 return 0;
673} 624}
674 625
675static int chp_add(struct chp_id chpid) 626int chsc_chp_online(struct chp_id chpid)
676{ 627{
677 int rc; 628 int rc;
678 char dbf_txt[15]; 629 char dbf_txt[15];
679 struct device *dev;
680 630
681 if (!get_chp_status(chpid))
682 return 0; /* no need to do the rest */
683
684 sprintf(dbf_txt, "cadd%x.%02x", chpid.cssid, chpid.id); 631 sprintf(dbf_txt, "cadd%x.%02x", chpid.cssid, chpid.id);
685 CIO_TRACE_EVENT(2, dbf_txt); 632 CIO_TRACE_EVENT(2, dbf_txt);
686 633
687 dev = get_device(&(chpid_to_chp(chpid)->dev)); 634 if (chp_get_status(chpid) == 0)
688 rc = for_each_subchannel(__chp_add, to_channelpath(dev)); 635 return 0;
636 rc = for_each_subchannel(__chp_add, &chpid);
689 if (css_slow_subchannels_exist()) 637 if (css_slow_subchannels_exist())
690 rc = -EAGAIN; 638 rc = -EAGAIN;
691 if (rc != -EAGAIN) 639 if (rc != -EAGAIN)
692 rc = 0; 640 rc = 0;
693 put_device(dev);
694 return rc; 641 return rc;
695} 642}
696 643
697/*
698 * Handling of crw machine checks with channel path source.
699 */
700int chp_process_crw(int id, int on)
701{
702 struct chp_id chpid;
703
704 chp_id_init(&chpid);
705 chpid.id = id;
706 if (on == 0) {
707 /* Path has gone. We use the link incident routine.*/
708 s390_set_chpid_offline(chpid);
709 return 0; /* De-register is async anyway. */
710 }
711 /*
712 * Path has come. Allocate a new channel path structure,
713 * if needed.
714 */
715 if (get_chp_status(chpid) < 0)
716 new_channel_path(chpid);
717 /* Avoid the extra overhead in process_rec_acc. */
718 return chp_add(chpid);
719}
720
721static int check_for_io_on_path(struct subchannel *sch, int index) 644static int check_for_io_on_path(struct subchannel *sch, int index)
722{ 645{
723 int cc; 646 int cc;
@@ -844,34 +767,13 @@ __s390_vary_chpid_on(struct subchannel_id schid, void *data)
844 return 0; 767 return 0;
845} 768}
846 769
847/* 770/**
848 * Function: s390_vary_chpid 771 * chsc_chp_vary - propagate channel-path vary operation to subchannels
849 * Varies the specified chpid online or offline 772 * @chpid: channl-path ID
773 * @on: non-zero for vary online, zero for vary offline
850 */ 774 */
851static int s390_vary_chpid(struct chp_id chpid, int on) 775int chsc_chp_vary(struct chp_id chpid, int on)
852{ 776{
853 char dbf_text[15];
854 int status;
855
856 sprintf(dbf_text, on?"varyon%x.%02x":"varyoff%x.%02x", chpid.cssid,
857 chpid.id);
858 CIO_TRACE_EVENT( 2, dbf_text);
859
860 status = get_chp_status(chpid);
861 if (status < 0) {
862 printk(KERN_ERR "Can't vary unknown chpid %x.%02x\n",
863 chpid.cssid, chpid.id);
864 return -EINVAL;
865 }
866
867 if (!on && !status) {
868 printk(KERN_ERR "chpid %x.%02x is already offline\n",
869 chpid.cssid, chpid.id);
870 return -EINVAL;
871 }
872
873 set_chp_logically_online(chpid, on);
874
875 /* 777 /*
876 * Redo PathVerification on the devices the chpid connects to 778 * Redo PathVerification on the devices the chpid connects to
877 */ 779 */
@@ -887,112 +789,6 @@ static int s390_vary_chpid(struct chp_id chpid, int on)
887 return 0; 789 return 0;
888} 790}
889 791
890/*
891 * Channel measurement related functions
892 */
893static ssize_t
894chp_measurement_chars_read(struct kobject *kobj, char *buf, loff_t off,
895 size_t count)
896{
897 struct channel_path *chp;
898 unsigned int size;
899
900 chp = to_channelpath(container_of(kobj, struct device, kobj));
901 if (!chp->cmg_chars)
902 return 0;
903
904 size = sizeof(struct cmg_chars);
905
906 if (off > size)
907 return 0;
908 if (off + count > size)
909 count = size - off;
910 memcpy(buf, chp->cmg_chars + off, count);
911 return count;
912}
913
914static struct bin_attribute chp_measurement_chars_attr = {
915 .attr = {
916 .name = "measurement_chars",
917 .mode = S_IRUSR,
918 .owner = THIS_MODULE,
919 },
920 .size = sizeof(struct cmg_chars),
921 .read = chp_measurement_chars_read,
922};
923
924static void chp_measurement_copy_block(struct cmg_entry *buf,
925 struct channel_subsystem *css, struct chp_id chpid)
926{
927 void *area;
928 struct cmg_entry *entry, reference_buf;
929 int idx;
930
931 if (chpid.id < 128) {
932 area = css->cub_addr1;
933 idx = chpid.id;
934 } else {
935 area = css->cub_addr2;
936 idx = chpid.id - 128;
937 }
938 entry = area + (idx * sizeof(struct cmg_entry));
939 do {
940 memcpy(buf, entry, sizeof(*entry));
941 memcpy(&reference_buf, entry, sizeof(*entry));
942 } while (reference_buf.values[0] != buf->values[0]);
943}
944
945static ssize_t
946chp_measurement_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
947{
948 struct channel_path *chp;
949 struct channel_subsystem *css;
950 unsigned int size;
951
952 chp = to_channelpath(container_of(kobj, struct device, kobj));
953 css = to_css(chp->dev.parent);
954
955 size = sizeof(struct cmg_entry);
956
957 /* Only allow single reads. */
958 if (off || count < size)
959 return 0;
960 chp_measurement_copy_block((struct cmg_entry *)buf, css, chp->chpid);
961 count = size;
962 return count;
963}
964
965static struct bin_attribute chp_measurement_attr = {
966 .attr = {
967 .name = "measurement",
968 .mode = S_IRUSR,
969 .owner = THIS_MODULE,
970 },
971 .size = sizeof(struct cmg_entry),
972 .read = chp_measurement_read,
973};
974
975static void
976chsc_remove_chp_cmg_attr(struct channel_path *chp)
977{
978 device_remove_bin_file(&chp->dev, &chp_measurement_chars_attr);
979 device_remove_bin_file(&chp->dev, &chp_measurement_attr);
980}
981
982static int
983chsc_add_chp_cmg_attr(struct channel_path *chp)
984{
985 int ret;
986
987 ret = device_create_bin_file(&chp->dev, &chp_measurement_chars_attr);
988 if (ret)
989 return ret;
990 ret = device_create_bin_file(&chp->dev, &chp_measurement_attr);
991 if (ret)
992 device_remove_bin_file(&chp->dev, &chp_measurement_chars_attr);
993 return ret;
994}
995
996static void 792static void
997chsc_remove_cmg_attr(struct channel_subsystem *css) 793chsc_remove_cmg_attr(struct channel_subsystem *css)
998{ 794{
@@ -1001,7 +797,7 @@ chsc_remove_cmg_attr(struct channel_subsystem *css)
1001 for (i = 0; i <= __MAX_CHPID; i++) { 797 for (i = 0; i <= __MAX_CHPID; i++) {
1002 if (!css->chps[i]) 798 if (!css->chps[i])
1003 continue; 799 continue;
1004 chsc_remove_chp_cmg_attr(css->chps[i]); 800 chp_remove_cmg_attr(css->chps[i]);
1005 } 801 }
1006} 802}
1007 803
@@ -1014,7 +810,7 @@ chsc_add_cmg_attr(struct channel_subsystem *css)
1014 for (i = 0; i <= __MAX_CHPID; i++) { 810 for (i = 0; i <= __MAX_CHPID; i++) {
1015 if (!css->chps[i]) 811 if (!css->chps[i])
1016 continue; 812 continue;
1017 ret = chsc_add_chp_cmg_attr(css->chps[i]); 813 ret = chp_add_cmg_attr(css->chps[i]);
1018 if (ret) 814 if (ret)
1019 goto cleanup; 815 goto cleanup;
1020 } 816 }
@@ -1023,12 +819,11 @@ cleanup:
1023 for (--i; i >= 0; i--) { 819 for (--i; i >= 0; i--) {
1024 if (!css->chps[i]) 820 if (!css->chps[i])
1025 continue; 821 continue;
1026 chsc_remove_chp_cmg_attr(css->chps[i]); 822 chp_remove_cmg_attr(css->chps[i]);
1027 } 823 }
1028 return ret; 824 return ret;
1029} 825}
1030 826
1031
1032static int 827static int
1033__chsc_do_secm(struct channel_subsystem *css, int enable, void *page) 828__chsc_do_secm(struct channel_subsystem *css, int enable, void *page)
1034{ 829{
@@ -1143,108 +938,8 @@ chsc_secm(struct channel_subsystem *css, int enable)
1143 return ret; 938 return ret;
1144} 939}
1145 940
1146/* 941int chsc_determine_channel_path_description(struct chp_id chpid,
1147 * Files for the channel path entries. 942 struct channel_path_desc *desc)
1148 */
1149static ssize_t
1150chp_status_show(struct device *dev, struct device_attribute *attr, char *buf)
1151{
1152 struct channel_path *chp = container_of(dev, struct channel_path, dev);
1153
1154 if (!chp)
1155 return 0;
1156 return (get_chp_status(chp->chpid) ? sprintf(buf, "online\n") :
1157 sprintf(buf, "offline\n"));
1158}
1159
1160static ssize_t
1161chp_status_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1162{
1163 struct channel_path *cp = container_of(dev, struct channel_path, dev);
1164 char cmd[10];
1165 int num_args;
1166 int error;
1167
1168 num_args = sscanf(buf, "%5s", cmd);
1169 if (!num_args)
1170 return count;
1171
1172 if (!strnicmp(cmd, "on", 2) || !strcmp(cmd, "1"))
1173 error = s390_vary_chpid(cp->chpid, 1);
1174 else if (!strnicmp(cmd, "off", 3) || !strcmp(cmd, "0"))
1175 error = s390_vary_chpid(cp->chpid, 0);
1176 else
1177 error = -EINVAL;
1178
1179 return error < 0 ? error : count;
1180
1181}
1182
1183static DEVICE_ATTR(status, 0644, chp_status_show, chp_status_write);
1184
1185static ssize_t
1186chp_type_show(struct device *dev, struct device_attribute *attr, char *buf)
1187{
1188 struct channel_path *chp = container_of(dev, struct channel_path, dev);
1189
1190 if (!chp)
1191 return 0;
1192 return sprintf(buf, "%x\n", chp->desc.desc);
1193}
1194
1195static DEVICE_ATTR(type, 0444, chp_type_show, NULL);
1196
1197static ssize_t
1198chp_cmg_show(struct device *dev, struct device_attribute *attr, char *buf)
1199{
1200 struct channel_path *chp = to_channelpath(dev);
1201
1202 if (!chp)
1203 return 0;
1204 if (chp->cmg == -1) /* channel measurements not available */
1205 return sprintf(buf, "unknown\n");
1206 return sprintf(buf, "%x\n", chp->cmg);
1207}
1208
1209static DEVICE_ATTR(cmg, 0444, chp_cmg_show, NULL);
1210
1211static ssize_t
1212chp_shared_show(struct device *dev, struct device_attribute *attr, char *buf)
1213{
1214 struct channel_path *chp = to_channelpath(dev);
1215
1216 if (!chp)
1217 return 0;
1218 if (chp->shared == -1) /* channel measurements not available */
1219 return sprintf(buf, "unknown\n");
1220 return sprintf(buf, "%x\n", chp->shared);
1221}
1222
1223static DEVICE_ATTR(shared, 0444, chp_shared_show, NULL);
1224
1225static struct attribute * chp_attrs[] = {
1226 &dev_attr_status.attr,
1227 &dev_attr_type.attr,
1228 &dev_attr_cmg.attr,
1229 &dev_attr_shared.attr,
1230 NULL,
1231};
1232
1233static struct attribute_group chp_attr_group = {
1234 .attrs = chp_attrs,
1235};
1236
1237static void
1238chp_release(struct device *dev)
1239{
1240 struct channel_path *cp;
1241
1242 cp = container_of(dev, struct channel_path, dev);
1243 kfree(cp);
1244}
1245
1246static int chsc_determine_channel_path_description(struct chp_id chpid,
1247 struct channel_path_desc *desc)
1248{ 943{
1249 int ccode, ret; 944 int ccode, ret;
1250 945
@@ -1331,8 +1026,7 @@ chsc_initialize_cmg_chars(struct channel_path *chp, u8 cmcv,
1331 } 1026 }
1332} 1027}
1333 1028
1334static int 1029int chsc_get_channel_measurement_chars(struct channel_path *chp)
1335chsc_get_channel_measurement_chars(struct channel_path *chp)
1336{ 1030{
1337 int ccode, ret; 1031 int ccode, ret;
1338 1032
@@ -1407,97 +1101,6 @@ out:
1407 return ret; 1101 return ret;
1408} 1102}
1409 1103
1410/*
1411 * Entries for chpids on the system bus.
1412 * This replaces /proc/chpids.
1413 */
1414static int new_channel_path(struct chp_id chpid)
1415{
1416 struct channel_path *chp;
1417 int ret;
1418
1419 chp = kzalloc(sizeof(struct channel_path), GFP_KERNEL);
1420 if (!chp)
1421 return -ENOMEM;
1422
1423 /* fill in status, etc. */
1424 chp->chpid = chpid;
1425 chp->state = 1;
1426 chp->dev.parent = &css[chpid.cssid]->device;
1427 chp->dev.release = chp_release;
1428 snprintf(chp->dev.bus_id, BUS_ID_SIZE, "chp%x.%02x", chpid.cssid,
1429 chpid.id);
1430
1431 /* Obtain channel path description and fill it in. */
1432 ret = chsc_determine_channel_path_description(chpid, &chp->desc);
1433 if (ret)
1434 goto out_free;
1435 /* Get channel-measurement characteristics. */
1436 if (css_characteristics_avail && css_chsc_characteristics.scmc
1437 && css_chsc_characteristics.secm) {
1438 ret = chsc_get_channel_measurement_chars(chp);
1439 if (ret)
1440 goto out_free;
1441 } else {
1442 static int msg_done;
1443
1444 if (!msg_done) {
1445 printk(KERN_WARNING "cio: Channel measurements not "
1446 "available, continuing.\n");
1447 msg_done = 1;
1448 }
1449 chp->cmg = -1;
1450 }
1451
1452 /* make it known to the system */
1453 ret = device_register(&chp->dev);
1454 if (ret) {
1455 printk(KERN_WARNING "%s: could not register %x.%02x\n",
1456 __func__, chpid.cssid, chpid.id);
1457 goto out_free;
1458 }
1459 ret = sysfs_create_group(&chp->dev.kobj, &chp_attr_group);
1460 if (ret) {
1461 device_unregister(&chp->dev);
1462 goto out_free;
1463 }
1464 mutex_lock(&css[chpid.cssid]->mutex);
1465 if (css[chpid.cssid]->cm_enabled) {
1466 ret = chsc_add_chp_cmg_attr(chp);
1467 if (ret) {
1468 sysfs_remove_group(&chp->dev.kobj, &chp_attr_group);
1469 device_unregister(&chp->dev);
1470 mutex_unlock(&css[chpid.cssid]->mutex);
1471 goto out_free;
1472 }
1473 }
1474 css[chpid.cssid]->chps[chpid.id] = chp;
1475 mutex_unlock(&css[chpid.cssid]->mutex);
1476 return ret;
1477out_free:
1478 kfree(chp);
1479 return ret;
1480}
1481
1482void *
1483chsc_get_chp_desc(struct subchannel *sch, int chp_no)
1484{
1485 struct channel_path *chp;
1486 struct channel_path_desc *desc;
1487 struct chp_id chpid;
1488
1489 chp_id_init(&chpid);
1490 chpid.id = sch->schib.pmcw.chpid[chp_no];
1491 chp = chpid_to_chp(chpid);
1492 if (!chp)
1493 return NULL;
1494 desc = kmalloc(sizeof(struct channel_path_desc), GFP_KERNEL);
1495 if (!desc)
1496 return NULL;
1497 memcpy(desc, &chp->desc, sizeof(struct channel_path_desc));
1498 return desc;
1499}
1500
1501static int __init 1104static int __init
1502chsc_alloc_sei_area(void) 1105chsc_alloc_sei_area(void)
1503{ 1106{
diff --git a/drivers/s390/cio/chsc.h b/drivers/s390/cio/chsc.h
index 2949c85b6d92..0e40defc6087 100644
--- a/drivers/s390/cio/chsc.h
+++ b/drivers/s390/cio/chsc.h
@@ -5,10 +5,6 @@
5#include <linux/device.h> 5#include <linux/device.h>
6#include "chpid.h" 6#include "chpid.h"
7 7
8#define CHSC_SEI_ACC_CHPID 1
9#define CHSC_SEI_ACC_LINKADDR 2
10#define CHSC_SEI_ACC_FULLLINKADDR 3
11
12#define CHSC_SDA_OC_MSS 0x2 8#define CHSC_SDA_OC_MSS 0x2
13 9
14struct chsc_header { 10struct chsc_header {
@@ -37,23 +33,10 @@ struct channel_path_desc {
37 u8 chpp; 33 u8 chpp;
38} __attribute__ ((packed)); 34} __attribute__ ((packed));
39 35
40struct channel_path { 36struct channel_path;
41 struct chp_id chpid;
42 int state;
43 struct channel_path_desc desc;
44 /* Channel-measurement related stuff: */
45 int cmg;
46 int shared;
47 void *cmg_chars;
48 struct device dev;
49};
50 37
51extern void s390_process_css( void );
52extern void chsc_validate_chpids(struct subchannel *);
53extern void chpid_is_actually_online(struct chp_id);
54extern int css_get_ssd_info(struct subchannel *); 38extern int css_get_ssd_info(struct subchannel *);
55extern int chsc_process_crw(void); 39extern int chsc_process_crw(void);
56extern int chp_process_crw(int, int);
57 40
58struct css_general_char { 41struct css_general_char {
59 u64 : 41; 42 u64 : 41;
@@ -89,12 +72,15 @@ extern struct css_chsc_char css_chsc_characteristics;
89extern int chsc_determine_css_characteristics(void); 72extern int chsc_determine_css_characteristics(void);
90extern int css_characteristics_avail; 73extern int css_characteristics_avail;
91 74
92extern void *chsc_get_chp_desc(struct subchannel*, int);
93
94extern int chsc_enable_facility(int); 75extern int chsc_enable_facility(int);
95struct channel_subsystem; 76struct channel_subsystem;
96extern int chsc_secm(struct channel_subsystem *, int); 77extern int chsc_secm(struct channel_subsystem *, int);
97 78
98#define to_channelpath(device) container_of(device, struct channel_path, dev) 79int chsc_chp_vary(struct chp_id chpid, int on);
80int chsc_determine_channel_path_description(struct chp_id chpid,
81 struct channel_path_desc *desc);
82int chsc_chp_online(struct chp_id chpid);
83void chsc_chp_offline(struct chp_id chpid);
84int chsc_get_channel_measurement_chars(struct channel_path *chp);
99 85
100#endif 86#endif
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c
index bab729202f49..7dd0649c95d1 100644
--- a/drivers/s390/cio/cio.c
+++ b/drivers/s390/cio/cio.c
@@ -29,6 +29,7 @@
29#include "ioasm.h" 29#include "ioasm.h"
30#include "blacklist.h" 30#include "blacklist.h"
31#include "cio_debug.h" 31#include "cio_debug.h"
32#include "chp.h"
32#include "../s390mach.h" 33#include "../s390mach.h"
33 34
34debug_info_t *cio_debug_msg_id; 35debug_info_t *cio_debug_msg_id;
@@ -592,9 +593,10 @@ cio_validate_subchannel (struct subchannel *sch, struct subchannel_id schid)
592 err = -ENODEV; 593 err = -ENODEV;
593 goto out; 594 goto out;
594 } 595 }
595 sch->opm = 0xff; 596 if (cio_is_console(sch->schid))
596 if (!cio_is_console(sch->schid)) 597 sch->opm = 0xff;
597 chsc_validate_chpids(sch); 598 else
599 sch->opm = chp_get_sch_opm(sch);
598 sch->lpm = sch->schib.pmcw.pam & sch->opm; 600 sch->lpm = sch->schib.pmcw.pam & sch->opm;
599 601
600 CIO_DEBUG(KERN_INFO, 0, 602 CIO_DEBUG(KERN_INFO, 0,
diff --git a/drivers/s390/cio/css.h b/drivers/s390/cio/css.h
index ca2bab932a8a..4319e1ced791 100644
--- a/drivers/s390/cio/css.h
+++ b/drivers/s390/cio/css.h
@@ -4,6 +4,7 @@
4#include <linux/mutex.h> 4#include <linux/mutex.h>
5#include <linux/wait.h> 5#include <linux/wait.h>
6#include <linux/workqueue.h> 6#include <linux/workqueue.h>
7#include <linux/device.h>
7 8
8#include <asm/cio.h> 9#include <asm/cio.h>
9 10
diff --git a/drivers/s390/cio/device_fsm.c b/drivers/s390/cio/device_fsm.c
index 5f5ee1eef07a..db3d1b990f58 100644
--- a/drivers/s390/cio/device_fsm.c
+++ b/drivers/s390/cio/device_fsm.c
@@ -23,6 +23,7 @@
23#include "chsc.h" 23#include "chsc.h"
24#include "ioasm.h" 24#include "ioasm.h"
25#include "chpid.h" 25#include "chpid.h"
26#include "chp.h"
26 27
27int 28int
28device_is_online(struct subchannel *sch) 29device_is_online(struct subchannel *sch)
@@ -221,7 +222,10 @@ __recover_lost_chpids(struct subchannel *sch, int old_lpm)
221 if (old_lpm & mask) 222 if (old_lpm & mask)
222 continue; 223 continue;
223 chpid.id = sch->schib.pmcw.chpid[i]; 224 chpid.id = sch->schib.pmcw.chpid[i];
224 chpid_is_actually_online(chpid); 225 if (!chp_is_registered(chpid)) {
226 need_rescan = 1;
227 queue_work(slow_path_wq, &slow_path_work);
228 }
225 } 229 }
226} 230}
227 231
diff --git a/drivers/s390/cio/device_ops.c b/drivers/s390/cio/device_ops.c
index 7c7775aae38a..d819ae2ee9ae 100644
--- a/drivers/s390/cio/device_ops.c
+++ b/drivers/s390/cio/device_ops.c
@@ -22,6 +22,8 @@
22#include "css.h" 22#include "css.h"
23#include "chsc.h" 23#include "chsc.h"
24#include "device.h" 24#include "device.h"
25#include "chpid.h"
26#include "chp.h"
25 27
26int ccw_device_set_options_mask(struct ccw_device *cdev, unsigned long flags) 28int ccw_device_set_options_mask(struct ccw_device *cdev, unsigned long flags)
27{ 29{
@@ -606,9 +608,12 @@ void *
606ccw_device_get_chp_desc(struct ccw_device *cdev, int chp_no) 608ccw_device_get_chp_desc(struct ccw_device *cdev, int chp_no)
607{ 609{
608 struct subchannel *sch; 610 struct subchannel *sch;
611 struct chp_id chpid;
609 612
610 sch = to_subchannel(cdev->dev.parent); 613 sch = to_subchannel(cdev->dev.parent);
611 return chsc_get_chp_desc(sch, chp_no); 614 chp_id_init(&chpid);
615 chpid.id = sch->schib.pmcw.chpid[chp_no];
616 return chp_get_chp_desc(chpid);
612} 617}
613 618
614// FIXME: these have to go: 619// FIXME: these have to go:
diff --git a/drivers/s390/s390mach.c b/drivers/s390/s390mach.c
index 806bb1a921eb..afd8a3c0f8d6 100644
--- a/drivers/s390/s390mach.c
+++ b/drivers/s390/s390mach.c
@@ -21,6 +21,7 @@
21#include "cio/cio.h" 21#include "cio/cio.h"
22#include "cio/chsc.h" 22#include "cio/chsc.h"
23#include "cio/css.h" 23#include "cio/css.h"
24#include "cio/chp.h"
24#include "s390mach.h" 25#include "s390mach.h"
25 26
26static struct semaphore m_sem; 27static struct semaphore m_sem;