Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * drivers/s390/cio/device_status.c |
| 3 | * |
| 4 | * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, |
| 5 | * IBM Corporation |
Cornelia Huck | 4ce3b30 | 2006-01-14 13:21:04 -0800 | [diff] [blame] | 6 | * Author(s): Cornelia Huck (cornelia.huck@de.ibm.com) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * Martin Schwidefsky (schwidefsky@de.ibm.com) |
| 8 | * |
| 9 | * Status accumulation and basic sense functions. |
| 10 | */ |
| 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/module.h> |
| 13 | #include <linux/init.h> |
| 14 | |
| 15 | #include <asm/ccwdev.h> |
| 16 | #include <asm/cio.h> |
| 17 | |
| 18 | #include "cio.h" |
| 19 | #include "cio_debug.h" |
| 20 | #include "css.h" |
| 21 | #include "device.h" |
| 22 | #include "ioasm.h" |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 23 | #include "io_sch.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
| 25 | /* |
| 26 | * Check for any kind of channel or interface control check but don't |
| 27 | * issue the message for the console device |
| 28 | */ |
Heiko Carstens | 4d284ca | 2007-02-05 21:18:53 +0100 | [diff] [blame] | 29 | static void |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | ccw_device_msg_control_check(struct ccw_device *cdev, struct irb *irb) |
| 31 | { |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 32 | char dbf_text[15]; |
| 33 | |
| 34 | if (!scsw_is_valid_cstat(&irb->scsw) || |
| 35 | !(scsw_cstat(&irb->scsw) & (SCHN_STAT_CHN_DATA_CHK | |
| 36 | SCHN_STAT_CHN_CTRL_CHK | SCHN_STAT_INTF_CTRL_CHK))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | CIO_MSG_EVENT(0, "Channel-Check or Interface-Control-Check " |
| 39 | "received" |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 40 | " ... device %04x on subchannel 0.%x.%04x, dev_stat " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | ": %02X sch_stat : %02X\n", |
Cornelia Huck | 7896426 | 2006-10-11 15:31:38 +0200 | [diff] [blame] | 42 | cdev->private->dev_id.devno, cdev->private->schid.ssid, |
| 43 | cdev->private->schid.sch_no, |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 44 | scsw_dstat(&irb->scsw), scsw_cstat(&irb->scsw)); |
| 45 | sprintf(dbf_text, "chk%x", cdev->private->schid.sch_no); |
| 46 | CIO_TRACE_EVENT(0, dbf_text); |
| 47 | CIO_HEX_EVENT(0, irb, sizeof(struct irb)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | /* |
| 51 | * Some paths became not operational (pno bit in scsw is set). |
| 52 | */ |
| 53 | static void |
| 54 | ccw_device_path_notoper(struct ccw_device *cdev) |
| 55 | { |
| 56 | struct subchannel *sch; |
| 57 | |
| 58 | sch = to_subchannel(cdev->dev.parent); |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 59 | stsch (sch->schid, &sch->schib); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 61 | CIO_MSG_EVENT(0, "%s(0.%x.%04x) - path(s) %02x are " |
Harvey Harrison | 2a2cf6b | 2008-04-17 07:46:21 +0200 | [diff] [blame] | 62 | "not operational \n", __func__, |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 63 | sch->schid.ssid, sch->schid.sch_no, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | sch->schib.pmcw.pnom); |
| 65 | |
| 66 | sch->lpm &= ~sch->schib.pmcw.pnom; |
Cornelia Huck | 7e56081 | 2006-07-12 16:40:19 +0200 | [diff] [blame] | 67 | cdev->private->flags.doverify = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | /* |
| 71 | * Copy valid bits from the extended control word to device irb. |
| 72 | */ |
Heiko Carstens | 4d284ca | 2007-02-05 21:18:53 +0100 | [diff] [blame] | 73 | static void |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | ccw_device_accumulate_ecw(struct ccw_device *cdev, struct irb *irb) |
| 75 | { |
| 76 | /* |
| 77 | * Copy extended control bit if it is valid... yes there |
| 78 | * are condition that have to be met for the extended control |
| 79 | * bit to have meaning. Sick. |
| 80 | */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 81 | cdev->private->irb.scsw.cmd.ectl = 0; |
| 82 | if ((irb->scsw.cmd.stctl & SCSW_STCTL_ALERT_STATUS) && |
| 83 | !(irb->scsw.cmd.stctl & SCSW_STCTL_INTER_STATUS)) |
| 84 | cdev->private->irb.scsw.cmd.ectl = irb->scsw.cmd.ectl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | /* Check if extended control word is valid. */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 86 | if (!cdev->private->irb.scsw.cmd.ectl) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | return; |
| 88 | /* Copy concurrent sense / model dependent information. */ |
| 89 | memcpy (&cdev->private->irb.ecw, irb->ecw, sizeof (irb->ecw)); |
| 90 | } |
| 91 | |
| 92 | /* |
| 93 | * Check if extended status word is valid. |
| 94 | */ |
Heiko Carstens | 4d284ca | 2007-02-05 21:18:53 +0100 | [diff] [blame] | 95 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | ccw_device_accumulate_esw_valid(struct irb *irb) |
| 97 | { |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 98 | if (!irb->scsw.cmd.eswf && |
| 99 | (irb->scsw.cmd.stctl == SCSW_STCTL_STATUS_PEND)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | return 0; |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 101 | if (irb->scsw.cmd.stctl == |
| 102 | (SCSW_STCTL_INTER_STATUS|SCSW_STCTL_STATUS_PEND) && |
| 103 | !(irb->scsw.cmd.actl & SCSW_ACTL_SUSPENDED)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | return 0; |
| 105 | return 1; |
| 106 | } |
| 107 | |
| 108 | /* |
| 109 | * Copy valid bits from the extended status word to device irb. |
| 110 | */ |
Heiko Carstens | 4d284ca | 2007-02-05 21:18:53 +0100 | [diff] [blame] | 111 | static void |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | ccw_device_accumulate_esw(struct ccw_device *cdev, struct irb *irb) |
| 113 | { |
| 114 | struct irb *cdev_irb; |
| 115 | struct sublog *cdev_sublog, *sublog; |
| 116 | |
| 117 | if (!ccw_device_accumulate_esw_valid(irb)) |
| 118 | return; |
| 119 | |
| 120 | cdev_irb = &cdev->private->irb; |
| 121 | |
| 122 | /* Copy last path used mask. */ |
| 123 | cdev_irb->esw.esw1.lpum = irb->esw.esw1.lpum; |
| 124 | |
| 125 | /* Copy subchannel logout information if esw is of format 0. */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 126 | if (irb->scsw.cmd.eswf) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | cdev_sublog = &cdev_irb->esw.esw0.sublog; |
| 128 | sublog = &irb->esw.esw0.sublog; |
| 129 | /* Copy extended status flags. */ |
| 130 | cdev_sublog->esf = sublog->esf; |
| 131 | /* |
| 132 | * Copy fields that have a meaning for channel data check |
| 133 | * channel control check and interface control check. |
| 134 | */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 135 | if (irb->scsw.cmd.cstat & (SCHN_STAT_CHN_DATA_CHK | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | SCHN_STAT_CHN_CTRL_CHK | |
| 137 | SCHN_STAT_INTF_CTRL_CHK)) { |
| 138 | /* Copy ancillary report bit. */ |
| 139 | cdev_sublog->arep = sublog->arep; |
| 140 | /* Copy field-validity-flags. */ |
| 141 | cdev_sublog->fvf = sublog->fvf; |
| 142 | /* Copy storage access code. */ |
| 143 | cdev_sublog->sacc = sublog->sacc; |
| 144 | /* Copy termination code. */ |
| 145 | cdev_sublog->termc = sublog->termc; |
| 146 | /* Copy sequence code. */ |
| 147 | cdev_sublog->seqc = sublog->seqc; |
| 148 | } |
| 149 | /* Copy device status check. */ |
| 150 | cdev_sublog->devsc = sublog->devsc; |
| 151 | /* Copy secondary error. */ |
| 152 | cdev_sublog->serr = sublog->serr; |
| 153 | /* Copy i/o-error alert. */ |
| 154 | cdev_sublog->ioerr = sublog->ioerr; |
| 155 | /* Copy channel path timeout bit. */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 156 | if (irb->scsw.cmd.cstat & SCHN_STAT_INTF_CTRL_CHK) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | cdev_irb->esw.esw0.erw.cpt = irb->esw.esw0.erw.cpt; |
| 158 | /* Copy failing storage address validity flag. */ |
| 159 | cdev_irb->esw.esw0.erw.fsavf = irb->esw.esw0.erw.fsavf; |
| 160 | if (cdev_irb->esw.esw0.erw.fsavf) { |
| 161 | /* ... and copy the failing storage address. */ |
| 162 | memcpy(cdev_irb->esw.esw0.faddr, irb->esw.esw0.faddr, |
| 163 | sizeof (irb->esw.esw0.faddr)); |
| 164 | /* ... and copy the failing storage address format. */ |
| 165 | cdev_irb->esw.esw0.erw.fsaf = irb->esw.esw0.erw.fsaf; |
| 166 | } |
| 167 | /* Copy secondary ccw address validity bit. */ |
| 168 | cdev_irb->esw.esw0.erw.scavf = irb->esw.esw0.erw.scavf; |
| 169 | if (irb->esw.esw0.erw.scavf) |
| 170 | /* ... and copy the secondary ccw address. */ |
| 171 | cdev_irb->esw.esw0.saddr = irb->esw.esw0.saddr; |
| 172 | |
| 173 | } |
| 174 | /* FIXME: DCTI for format 2? */ |
| 175 | |
| 176 | /* Copy authorization bit. */ |
| 177 | cdev_irb->esw.esw0.erw.auth = irb->esw.esw0.erw.auth; |
| 178 | /* Copy path verification required flag. */ |
| 179 | cdev_irb->esw.esw0.erw.pvrf = irb->esw.esw0.erw.pvrf; |
Cornelia Huck | 7e56081 | 2006-07-12 16:40:19 +0200 | [diff] [blame] | 180 | if (irb->esw.esw0.erw.pvrf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | cdev->private->flags.doverify = 1; |
| 182 | /* Copy concurrent sense bit. */ |
| 183 | cdev_irb->esw.esw0.erw.cons = irb->esw.esw0.erw.cons; |
| 184 | if (irb->esw.esw0.erw.cons) |
| 185 | cdev_irb->esw.esw0.erw.scnt = irb->esw.esw0.erw.scnt; |
| 186 | } |
| 187 | |
| 188 | /* |
| 189 | * Accumulate status from irb to devstat. |
| 190 | */ |
| 191 | void |
| 192 | ccw_device_accumulate_irb(struct ccw_device *cdev, struct irb *irb) |
| 193 | { |
| 194 | struct irb *cdev_irb; |
| 195 | |
| 196 | /* |
| 197 | * Check if the status pending bit is set in stctl. |
| 198 | * If not, the remaining bit have no meaning and we must ignore them. |
| 199 | * The esw is not meaningful as well... |
| 200 | */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 201 | if (!(scsw_stctl(&irb->scsw) & SCSW_STCTL_STATUS_PEND)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | return; |
| 203 | |
| 204 | /* Check for channel checks and interface control checks. */ |
| 205 | ccw_device_msg_control_check(cdev, irb); |
| 206 | |
| 207 | /* Check for path not operational. */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 208 | if (scsw_is_valid_pno(&irb->scsw) && scsw_pno(&irb->scsw)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | ccw_device_path_notoper(cdev); |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 210 | /* No irb accumulation for transport mode irbs. */ |
| 211 | if (scsw_is_tm(&irb->scsw)) { |
| 212 | memcpy(&cdev->private->irb, irb, sizeof(struct irb)); |
| 213 | return; |
| 214 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | /* |
| 216 | * Don't accumulate unsolicited interrupts. |
| 217 | */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 218 | if (!scsw_is_solicited(&irb->scsw)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | return; |
| 220 | |
| 221 | cdev_irb = &cdev->private->irb; |
| 222 | |
Cornelia Huck | 8c3ce5b | 2007-04-04 14:37:11 +0200 | [diff] [blame] | 223 | /* |
| 224 | * If the clear function had been performed, all formerly pending |
| 225 | * status at the subchannel has been cleared and we must not pass |
| 226 | * intermediate accumulated status to the device driver. |
| 227 | */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 228 | if (irb->scsw.cmd.fctl & SCSW_FCTL_CLEAR_FUNC) |
Cornelia Huck | 8c3ce5b | 2007-04-04 14:37:11 +0200 | [diff] [blame] | 229 | memset(&cdev->private->irb, 0, sizeof(struct irb)); |
| 230 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | /* Copy bits which are valid only for the start function. */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 232 | if (irb->scsw.cmd.fctl & SCSW_FCTL_START_FUNC) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | /* Copy key. */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 234 | cdev_irb->scsw.cmd.key = irb->scsw.cmd.key; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | /* Copy suspend control bit. */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 236 | cdev_irb->scsw.cmd.sctl = irb->scsw.cmd.sctl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | /* Accumulate deferred condition code. */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 238 | cdev_irb->scsw.cmd.cc |= irb->scsw.cmd.cc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | /* Copy ccw format bit. */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 240 | cdev_irb->scsw.cmd.fmt = irb->scsw.cmd.fmt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | /* Copy prefetch bit. */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 242 | cdev_irb->scsw.cmd.pfch = irb->scsw.cmd.pfch; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | /* Copy initial-status-interruption-control. */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 244 | cdev_irb->scsw.cmd.isic = irb->scsw.cmd.isic; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | /* Copy address limit checking control. */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 246 | cdev_irb->scsw.cmd.alcc = irb->scsw.cmd.alcc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | /* Copy suppress suspend bit. */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 248 | cdev_irb->scsw.cmd.ssi = irb->scsw.cmd.ssi; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | /* Take care of the extended control bit and extended control word. */ |
| 252 | ccw_device_accumulate_ecw(cdev, irb); |
| 253 | |
| 254 | /* Accumulate function control. */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 255 | cdev_irb->scsw.cmd.fctl |= irb->scsw.cmd.fctl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | /* Copy activity control. */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 257 | cdev_irb->scsw.cmd.actl = irb->scsw.cmd.actl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | /* Accumulate status control. */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 259 | cdev_irb->scsw.cmd.stctl |= irb->scsw.cmd.stctl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | /* |
| 261 | * Copy ccw address if it is valid. This is a bit simplified |
| 262 | * but should be close enough for all practical purposes. |
| 263 | */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 264 | if ((irb->scsw.cmd.stctl & SCSW_STCTL_PRIM_STATUS) || |
| 265 | ((irb->scsw.cmd.stctl == |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | (SCSW_STCTL_INTER_STATUS|SCSW_STCTL_STATUS_PEND)) && |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 267 | (irb->scsw.cmd.actl & SCSW_ACTL_DEVACT) && |
| 268 | (irb->scsw.cmd.actl & SCSW_ACTL_SCHACT)) || |
| 269 | (irb->scsw.cmd.actl & SCSW_ACTL_SUSPENDED)) |
| 270 | cdev_irb->scsw.cmd.cpa = irb->scsw.cmd.cpa; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | /* Accumulate device status, but not the device busy flag. */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 272 | cdev_irb->scsw.cmd.dstat &= ~DEV_STAT_BUSY; |
Cornelia Huck | 25c61a1 | 2007-03-26 20:42:41 +0200 | [diff] [blame] | 273 | /* dstat is not always valid. */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 274 | if (irb->scsw.cmd.stctl & |
Cornelia Huck | 25c61a1 | 2007-03-26 20:42:41 +0200 | [diff] [blame] | 275 | (SCSW_STCTL_PRIM_STATUS | SCSW_STCTL_SEC_STATUS |
| 276 | | SCSW_STCTL_INTER_STATUS | SCSW_STCTL_ALERT_STATUS)) |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 277 | cdev_irb->scsw.cmd.dstat |= irb->scsw.cmd.dstat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | /* Accumulate subchannel status. */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 279 | cdev_irb->scsw.cmd.cstat |= irb->scsw.cmd.cstat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | /* Copy residual count if it is valid. */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 281 | if ((irb->scsw.cmd.stctl & SCSW_STCTL_PRIM_STATUS) && |
| 282 | (irb->scsw.cmd.cstat & ~(SCHN_STAT_PCI | SCHN_STAT_INCORR_LEN)) |
| 283 | == 0) |
| 284 | cdev_irb->scsw.cmd.count = irb->scsw.cmd.count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | |
| 286 | /* Take care of bits in the extended status word. */ |
| 287 | ccw_device_accumulate_esw(cdev, irb); |
| 288 | |
| 289 | /* |
| 290 | * Check whether we must issue a SENSE CCW ourselves if there is no |
| 291 | * concurrent sense facility installed for the subchannel. |
| 292 | * No sense is required if no delayed sense is pending |
| 293 | * and we did not get a unit check without sense information. |
| 294 | * |
| 295 | * Note: We should check for ioinfo[irq]->flags.consns but VM |
| 296 | * violates the ESA/390 architecture and doesn't present an |
| 297 | * operand exception for virtual devices without concurrent |
| 298 | * sense facility available/supported when enabling the |
| 299 | * concurrent sense facility. |
| 300 | */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 301 | if ((cdev_irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | !(cdev_irb->esw.esw0.erw.cons)) |
| 303 | cdev->private->flags.dosense = 1; |
| 304 | } |
| 305 | |
| 306 | /* |
| 307 | * Do a basic sense. |
| 308 | */ |
| 309 | int |
| 310 | ccw_device_do_sense(struct ccw_device *cdev, struct irb *irb) |
| 311 | { |
| 312 | struct subchannel *sch; |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 313 | struct ccw1 *sense_ccw; |
Cornelia Huck | fe6173d | 2008-04-17 07:46:00 +0200 | [diff] [blame] | 314 | int rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | |
| 316 | sch = to_subchannel(cdev->dev.parent); |
| 317 | |
| 318 | /* A sense is required, can we do it now ? */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 319 | if (scsw_actl(&irb->scsw) & (SCSW_ACTL_DEVACT | SCSW_ACTL_SCHACT)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | /* |
| 321 | * we received an Unit Check but we have no final |
| 322 | * status yet, therefore we must delay the SENSE |
| 323 | * processing. We must not report this intermediate |
| 324 | * status to the device interrupt handler. |
| 325 | */ |
| 326 | return -EBUSY; |
| 327 | |
| 328 | /* |
| 329 | * We have ending status but no sense information. Do a basic sense. |
| 330 | */ |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 331 | sense_ccw = &to_io_private(sch)->sense_ccw; |
| 332 | sense_ccw->cmd_code = CCW_CMD_BASIC_SENSE; |
| 333 | sense_ccw->cda = (__u32) __pa(cdev->private->irb.ecw); |
| 334 | sense_ccw->count = SENSE_MAX_COUNT; |
| 335 | sense_ccw->flags = CCW_FLAG_SLI; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | |
Cornelia Huck | d23861f | 2006-12-04 15:41:04 +0100 | [diff] [blame] | 337 | /* Reset internal retry indication. */ |
| 338 | cdev->private->flags.intretry = 0; |
| 339 | |
Cornelia Huck | fe6173d | 2008-04-17 07:46:00 +0200 | [diff] [blame] | 340 | rc = cio_start(sch, sense_ccw, 0xff); |
| 341 | if (rc == -ENODEV || rc == -EACCES) |
| 342 | dev_fsm_event(cdev, DEV_EVENT_VERIFY); |
| 343 | return rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | /* |
| 347 | * Add information from basic sense to devstat. |
| 348 | */ |
| 349 | void |
| 350 | ccw_device_accumulate_basic_sense(struct ccw_device *cdev, struct irb *irb) |
| 351 | { |
| 352 | /* |
| 353 | * Check if the status pending bit is set in stctl. |
| 354 | * If not, the remaining bit have no meaning and we must ignore them. |
| 355 | * The esw is not meaningful as well... |
| 356 | */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 357 | if (!(scsw_stctl(&irb->scsw) & SCSW_STCTL_STATUS_PEND)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | return; |
| 359 | |
| 360 | /* Check for channel checks and interface control checks. */ |
| 361 | ccw_device_msg_control_check(cdev, irb); |
| 362 | |
| 363 | /* Check for path not operational. */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 364 | if (scsw_is_valid_pno(&irb->scsw) && scsw_pno(&irb->scsw)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | ccw_device_path_notoper(cdev); |
| 366 | |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 367 | if (!(irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) && |
| 368 | (irb->scsw.cmd.dstat & DEV_STAT_CHN_END)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | cdev->private->irb.esw.esw0.erw.cons = 1; |
| 370 | cdev->private->flags.dosense = 0; |
| 371 | } |
| 372 | /* Check if path verification is required. */ |
| 373 | if (ccw_device_accumulate_esw_valid(irb) && |
Cornelia Huck | 7e56081 | 2006-07-12 16:40:19 +0200 | [diff] [blame] | 374 | irb->esw.esw0.erw.pvrf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | cdev->private->flags.doverify = 1; |
| 376 | } |
| 377 | |
| 378 | /* |
| 379 | * This function accumulates the status into the private devstat and |
| 380 | * starts a basic sense if one is needed. |
| 381 | */ |
| 382 | int |
| 383 | ccw_device_accumulate_and_sense(struct ccw_device *cdev, struct irb *irb) |
| 384 | { |
| 385 | ccw_device_accumulate_irb(cdev, irb); |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 386 | if ((irb->scsw.cmd.actl & (SCSW_ACTL_DEVACT | SCSW_ACTL_SCHACT)) != 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | return -EBUSY; |
| 388 | /* Check for basic sense. */ |
| 389 | if (cdev->private->flags.dosense && |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame^] | 390 | !(irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | cdev->private->irb.esw.esw0.erw.cons = 1; |
| 392 | cdev->private->flags.dosense = 0; |
| 393 | return 0; |
| 394 | } |
| 395 | if (cdev->private->flags.dosense) { |
| 396 | ccw_device_do_sense(cdev, irb); |
| 397 | return -EBUSY; |
| 398 | } |
| 399 | return 0; |
| 400 | } |
| 401 | |