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