This source file includes following definitions.
- ccw_device_msg_control_check
- ccw_device_path_notoper
- ccw_device_accumulate_ecw
- ccw_device_accumulate_esw_valid
- ccw_device_accumulate_esw
- ccw_device_accumulate_irb
- ccw_device_do_sense
- ccw_device_accumulate_basic_sense
- ccw_device_accumulate_and_sense
1
2
3
4
5
6
7
8
9
10 #include <linux/module.h>
11 #include <linux/init.h>
12
13 #include <asm/ccwdev.h>
14 #include <asm/cio.h>
15
16 #include "cio.h"
17 #include "cio_debug.h"
18 #include "css.h"
19 #include "device.h"
20 #include "ioasm.h"
21 #include "io_sch.h"
22
23
24
25
26
27 static void
28 ccw_device_msg_control_check(struct ccw_device *cdev, struct irb *irb)
29 {
30 struct subchannel *sch = to_subchannel(cdev->dev.parent);
31 char dbf_text[15];
32
33 if (!scsw_is_valid_cstat(&irb->scsw) ||
34 !(scsw_cstat(&irb->scsw) & (SCHN_STAT_CHN_DATA_CHK |
35 SCHN_STAT_CHN_CTRL_CHK | SCHN_STAT_INTF_CTRL_CHK)))
36 return;
37 CIO_MSG_EVENT(0, "Channel-Check or Interface-Control-Check "
38 "received"
39 " ... device %04x on subchannel 0.%x.%04x, dev_stat "
40 ": %02X sch_stat : %02X\n",
41 cdev->private->dev_id.devno, sch->schid.ssid,
42 sch->schid.sch_no,
43 scsw_dstat(&irb->scsw), scsw_cstat(&irb->scsw));
44 sprintf(dbf_text, "chk%x", sch->schid.sch_no);
45 CIO_TRACE_EVENT(0, dbf_text);
46 CIO_HEX_EVENT(0, irb, sizeof(struct irb));
47 }
48
49
50
51
52 static void
53 ccw_device_path_notoper(struct ccw_device *cdev)
54 {
55 struct subchannel *sch;
56
57 sch = to_subchannel(cdev->dev.parent);
58 if (cio_update_schib(sch))
59 goto doverify;
60
61 CIO_MSG_EVENT(0, "%s(0.%x.%04x) - path(s) %02x are "
62 "not operational \n", __func__,
63 sch->schid.ssid, sch->schid.sch_no,
64 sch->schib.pmcw.pnom);
65
66 sch->lpm &= ~sch->schib.pmcw.pnom;
67 doverify:
68 cdev->private->flags.doverify = 1;
69 }
70
71
72
73
74 static void
75 ccw_device_accumulate_ecw(struct ccw_device *cdev, struct irb *irb)
76 {
77
78
79
80
81
82 cdev->private->dma_area->irb.scsw.cmd.ectl = 0;
83 if ((irb->scsw.cmd.stctl & SCSW_STCTL_ALERT_STATUS) &&
84 !(irb->scsw.cmd.stctl & SCSW_STCTL_INTER_STATUS))
85 cdev->private->dma_area->irb.scsw.cmd.ectl = irb->scsw.cmd.ectl;
86
87 if (!cdev->private->dma_area->irb.scsw.cmd.ectl)
88 return;
89
90 memcpy(&cdev->private->dma_area->irb.ecw, irb->ecw, sizeof(irb->ecw));
91 }
92
93
94
95
96 static int
97 ccw_device_accumulate_esw_valid(struct irb *irb)
98 {
99 if (!irb->scsw.cmd.eswf &&
100 (irb->scsw.cmd.stctl == SCSW_STCTL_STATUS_PEND))
101 return 0;
102 if (irb->scsw.cmd.stctl ==
103 (SCSW_STCTL_INTER_STATUS|SCSW_STCTL_STATUS_PEND) &&
104 !(irb->scsw.cmd.actl & SCSW_ACTL_SUSPENDED))
105 return 0;
106 return 1;
107 }
108
109
110
111
112 static void
113 ccw_device_accumulate_esw(struct ccw_device *cdev, struct irb *irb)
114 {
115 struct irb *cdev_irb;
116 struct sublog *cdev_sublog, *sublog;
117
118 if (!ccw_device_accumulate_esw_valid(irb))
119 return;
120
121 cdev_irb = &cdev->private->dma_area->irb;
122
123
124 cdev_irb->esw.esw1.lpum = irb->esw.esw1.lpum;
125
126
127 if (irb->scsw.cmd.eswf) {
128 cdev_sublog = &cdev_irb->esw.esw0.sublog;
129 sublog = &irb->esw.esw0.sublog;
130
131 cdev_sublog->esf = sublog->esf;
132
133
134
135
136 if (irb->scsw.cmd.cstat & (SCHN_STAT_CHN_DATA_CHK |
137 SCHN_STAT_CHN_CTRL_CHK |
138 SCHN_STAT_INTF_CTRL_CHK)) {
139
140 cdev_sublog->arep = sublog->arep;
141
142 cdev_sublog->fvf = sublog->fvf;
143
144 cdev_sublog->sacc = sublog->sacc;
145
146 cdev_sublog->termc = sublog->termc;
147
148 cdev_sublog->seqc = sublog->seqc;
149 }
150
151 cdev_sublog->devsc = sublog->devsc;
152
153 cdev_sublog->serr = sublog->serr;
154
155 cdev_sublog->ioerr = sublog->ioerr;
156
157 if (irb->scsw.cmd.cstat & SCHN_STAT_INTF_CTRL_CHK)
158 cdev_irb->esw.esw0.erw.cpt = irb->esw.esw0.erw.cpt;
159
160 cdev_irb->esw.esw0.erw.fsavf = irb->esw.esw0.erw.fsavf;
161 if (cdev_irb->esw.esw0.erw.fsavf) {
162
163 memcpy(cdev_irb->esw.esw0.faddr, irb->esw.esw0.faddr,
164 sizeof (irb->esw.esw0.faddr));
165
166 cdev_irb->esw.esw0.erw.fsaf = irb->esw.esw0.erw.fsaf;
167 }
168
169 cdev_irb->esw.esw0.erw.scavf = irb->esw.esw0.erw.scavf;
170 if (irb->esw.esw0.erw.scavf)
171
172 cdev_irb->esw.esw0.saddr = irb->esw.esw0.saddr;
173
174 }
175
176
177
178 cdev_irb->esw.esw0.erw.auth = irb->esw.esw0.erw.auth;
179
180 cdev_irb->esw.esw0.erw.pvrf = irb->esw.esw0.erw.pvrf;
181 if (irb->esw.esw0.erw.pvrf)
182 cdev->private->flags.doverify = 1;
183
184 cdev_irb->esw.esw0.erw.cons = irb->esw.esw0.erw.cons;
185 if (irb->esw.esw0.erw.cons)
186 cdev_irb->esw.esw0.erw.scnt = irb->esw.esw0.erw.scnt;
187 }
188
189
190
191
192 void
193 ccw_device_accumulate_irb(struct ccw_device *cdev, struct irb *irb)
194 {
195 struct irb *cdev_irb;
196
197
198
199
200
201
202 if (!(scsw_stctl(&irb->scsw) & SCSW_STCTL_STATUS_PEND))
203 return;
204
205
206 ccw_device_msg_control_check(cdev, irb);
207
208
209 if (scsw_is_valid_pno(&irb->scsw) && scsw_pno(&irb->scsw))
210 ccw_device_path_notoper(cdev);
211
212 if (scsw_is_tm(&irb->scsw)) {
213 memcpy(&cdev->private->dma_area->irb, irb, sizeof(struct irb));
214 return;
215 }
216
217
218
219 if (!scsw_is_solicited(&irb->scsw))
220 return;
221
222 cdev_irb = &cdev->private->dma_area->irb;
223
224
225
226
227
228
229 if (irb->scsw.cmd.fctl & SCSW_FCTL_CLEAR_FUNC)
230 memset(&cdev->private->dma_area->irb, 0, sizeof(struct irb));
231
232
233 if (irb->scsw.cmd.fctl & SCSW_FCTL_START_FUNC) {
234
235 cdev_irb->scsw.cmd.key = irb->scsw.cmd.key;
236
237 cdev_irb->scsw.cmd.sctl = irb->scsw.cmd.sctl;
238
239 cdev_irb->scsw.cmd.cc |= irb->scsw.cmd.cc;
240
241 cdev_irb->scsw.cmd.fmt = irb->scsw.cmd.fmt;
242
243 cdev_irb->scsw.cmd.pfch = irb->scsw.cmd.pfch;
244
245 cdev_irb->scsw.cmd.isic = irb->scsw.cmd.isic;
246
247 cdev_irb->scsw.cmd.alcc = irb->scsw.cmd.alcc;
248
249 cdev_irb->scsw.cmd.ssi = irb->scsw.cmd.ssi;
250 }
251
252
253 ccw_device_accumulate_ecw(cdev, irb);
254
255
256 cdev_irb->scsw.cmd.fctl |= irb->scsw.cmd.fctl;
257
258 cdev_irb->scsw.cmd.actl = irb->scsw.cmd.actl;
259
260 cdev_irb->scsw.cmd.stctl |= irb->scsw.cmd.stctl;
261
262
263
264
265 if ((irb->scsw.cmd.stctl & SCSW_STCTL_PRIM_STATUS) ||
266 ((irb->scsw.cmd.stctl ==
267 (SCSW_STCTL_INTER_STATUS|SCSW_STCTL_STATUS_PEND)) &&
268 (irb->scsw.cmd.actl & SCSW_ACTL_DEVACT) &&
269 (irb->scsw.cmd.actl & SCSW_ACTL_SCHACT)) ||
270 (irb->scsw.cmd.actl & SCSW_ACTL_SUSPENDED))
271 cdev_irb->scsw.cmd.cpa = irb->scsw.cmd.cpa;
272
273 cdev_irb->scsw.cmd.dstat &= ~DEV_STAT_BUSY;
274
275 if (irb->scsw.cmd.stctl &
276 (SCSW_STCTL_PRIM_STATUS | SCSW_STCTL_SEC_STATUS
277 | SCSW_STCTL_INTER_STATUS | SCSW_STCTL_ALERT_STATUS))
278 cdev_irb->scsw.cmd.dstat |= irb->scsw.cmd.dstat;
279
280 cdev_irb->scsw.cmd.cstat |= irb->scsw.cmd.cstat;
281
282 if ((irb->scsw.cmd.stctl & SCSW_STCTL_PRIM_STATUS) &&
283 (irb->scsw.cmd.cstat & ~(SCHN_STAT_PCI | SCHN_STAT_INCORR_LEN))
284 == 0)
285 cdev_irb->scsw.cmd.count = irb->scsw.cmd.count;
286
287
288 ccw_device_accumulate_esw(cdev, irb);
289
290
291
292
293
294
295
296
297
298
299
300
301
302 if ((cdev_irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) &&
303 !(cdev_irb->esw.esw0.erw.cons))
304 cdev->private->flags.dosense = 1;
305 }
306
307
308
309
310 int
311 ccw_device_do_sense(struct ccw_device *cdev, struct irb *irb)
312 {
313 struct subchannel *sch;
314 struct ccw1 *sense_ccw;
315 int rc;
316
317 sch = to_subchannel(cdev->dev.parent);
318
319
320 if (scsw_actl(&irb->scsw) & (SCSW_ACTL_DEVACT | SCSW_ACTL_SCHACT))
321
322
323
324
325
326
327 return -EBUSY;
328
329
330
331
332 sense_ccw = &to_io_private(sch)->dma_area->sense_ccw;
333 sense_ccw->cmd_code = CCW_CMD_BASIC_SENSE;
334 sense_ccw->cda = (__u32) __pa(cdev->private->dma_area->irb.ecw);
335 sense_ccw->count = SENSE_MAX_COUNT;
336 sense_ccw->flags = CCW_FLAG_SLI;
337
338 rc = cio_start(sch, sense_ccw, 0xff);
339 if (rc == -ENODEV || rc == -EACCES)
340 dev_fsm_event(cdev, DEV_EVENT_VERIFY);
341 return rc;
342 }
343
344
345
346
347 void
348 ccw_device_accumulate_basic_sense(struct ccw_device *cdev, struct irb *irb)
349 {
350
351
352
353
354
355 if (!(scsw_stctl(&irb->scsw) & SCSW_STCTL_STATUS_PEND))
356 return;
357
358
359 ccw_device_msg_control_check(cdev, irb);
360
361
362 if (scsw_is_valid_pno(&irb->scsw) && scsw_pno(&irb->scsw))
363 ccw_device_path_notoper(cdev);
364
365 if (!(irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) &&
366 (irb->scsw.cmd.dstat & DEV_STAT_CHN_END)) {
367 cdev->private->dma_area->irb.esw.esw0.erw.cons = 1;
368 cdev->private->flags.dosense = 0;
369 }
370
371 if (ccw_device_accumulate_esw_valid(irb) &&
372 irb->esw.esw0.erw.pvrf)
373 cdev->private->flags.doverify = 1;
374 }
375
376
377
378
379
380 int
381 ccw_device_accumulate_and_sense(struct ccw_device *cdev, struct irb *irb)
382 {
383 ccw_device_accumulate_irb(cdev, irb);
384 if ((irb->scsw.cmd.actl & (SCSW_ACTL_DEVACT | SCSW_ACTL_SCHACT)) != 0)
385 return -EBUSY;
386
387 if (cdev->private->flags.dosense &&
388 !(irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK)) {
389 cdev->private->dma_area->irb.esw.esw0.erw.cons = 1;
390 cdev->private->flags.dosense = 0;
391 return 0;
392 }
393 if (cdev->private->flags.dosense) {
394 ccw_device_do_sense(cdev, irb);
395 return -EBUSY;
396 }
397 return 0;
398 }
399