| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
 | 2 |  * drivers/s390/cio/device_id.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 |  * Sense ID functions. | 
 | 10 |  */ | 
 | 11 |  | 
 | 12 | #include <linux/module.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/init.h> | 
| Ahmed S. Darwish | 045236a | 2007-02-12 15:49:51 +0100 | [diff] [blame] | 14 | #include <linux/kernel.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 |  | 
 | 16 | #include <asm/ccwdev.h> | 
 | 17 | #include <asm/delay.h> | 
 | 18 | #include <asm/cio.h> | 
 | 19 | #include <asm/lowcore.h> | 
| Michael Holzheu | 0a87c5c | 2007-08-22 13:51:40 +0200 | [diff] [blame] | 20 | #include <asm/diag.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 |  | 
 | 22 | #include "cio.h" | 
 | 23 | #include "cio_debug.h" | 
 | 24 | #include "css.h" | 
 | 25 | #include "device.h" | 
 | 26 | #include "ioasm.h" | 
| Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 27 | #include "io_sch.h" | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 |  | 
| Peter Oberparleiter | 6f52ac2 | 2008-02-05 16:50:33 +0100 | [diff] [blame] | 29 | /** | 
 | 30 |  * vm_vdev_to_cu_type - Convert vm virtual device into control unit type | 
 | 31 |  *			for certain devices. | 
 | 32 |  * @class: virtual device class | 
 | 33 |  * @type: virtual device type | 
 | 34 |  * | 
 | 35 |  * Returns control unit type if a match was made or %0xffff otherwise. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 |  */ | 
| Peter Oberparleiter | 6f52ac2 | 2008-02-05 16:50:33 +0100 | [diff] [blame] | 37 | static int vm_vdev_to_cu_type(int class, int type) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | { | 
 | 39 | 	static struct { | 
| Peter Oberparleiter | 6f52ac2 | 2008-02-05 16:50:33 +0100 | [diff] [blame] | 40 | 		int class, type, cu_type; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | 	} vm_devices[] = { | 
 | 42 | 		{ 0x08, 0x01, 0x3480 }, | 
 | 43 | 		{ 0x08, 0x02, 0x3430 }, | 
 | 44 | 		{ 0x08, 0x10, 0x3420 }, | 
 | 45 | 		{ 0x08, 0x42, 0x3424 }, | 
 | 46 | 		{ 0x08, 0x44, 0x9348 }, | 
 | 47 | 		{ 0x08, 0x81, 0x3490 }, | 
 | 48 | 		{ 0x08, 0x82, 0x3422 }, | 
 | 49 | 		{ 0x10, 0x41, 0x1403 }, | 
 | 50 | 		{ 0x10, 0x42, 0x3211 }, | 
 | 51 | 		{ 0x10, 0x43, 0x3203 }, | 
 | 52 | 		{ 0x10, 0x45, 0x3800 }, | 
 | 53 | 		{ 0x10, 0x47, 0x3262 }, | 
 | 54 | 		{ 0x10, 0x48, 0x3820 }, | 
 | 55 | 		{ 0x10, 0x49, 0x3800 }, | 
 | 56 | 		{ 0x10, 0x4a, 0x4245 }, | 
 | 57 | 		{ 0x10, 0x4b, 0x4248 }, | 
 | 58 | 		{ 0x10, 0x4d, 0x3800 }, | 
 | 59 | 		{ 0x10, 0x4e, 0x3820 }, | 
 | 60 | 		{ 0x10, 0x4f, 0x3820 }, | 
 | 61 | 		{ 0x10, 0x82, 0x2540 }, | 
 | 62 | 		{ 0x10, 0x84, 0x3525 }, | 
 | 63 | 		{ 0x20, 0x81, 0x2501 }, | 
 | 64 | 		{ 0x20, 0x82, 0x2540 }, | 
 | 65 | 		{ 0x20, 0x84, 0x3505 }, | 
 | 66 | 		{ 0x40, 0x01, 0x3278 }, | 
 | 67 | 		{ 0x40, 0x04, 0x3277 }, | 
 | 68 | 		{ 0x40, 0x80, 0x2250 }, | 
 | 69 | 		{ 0x40, 0xc0, 0x5080 }, | 
 | 70 | 		{ 0x80, 0x00, 0x3215 }, | 
 | 71 | 	}; | 
| Peter Oberparleiter | 6f52ac2 | 2008-02-05 16:50:33 +0100 | [diff] [blame] | 72 | 	int i; | 
 | 73 |  | 
 | 74 | 	for (i = 0; i < ARRAY_SIZE(vm_devices); i++) | 
 | 75 | 		if (class == vm_devices[i].class && type == vm_devices[i].type) | 
 | 76 | 			return vm_devices[i].cu_type; | 
 | 77 |  | 
 | 78 | 	return 0xffff; | 
 | 79 | } | 
 | 80 |  | 
 | 81 | /** | 
 | 82 |  * diag_get_dev_info - retrieve device information via DIAG X'210' | 
 | 83 |  * @devno: device number | 
 | 84 |  * @ps: pointer to sense ID data area | 
 | 85 |  * | 
 | 86 |  * Returns zero on success, non-zero otherwise. | 
 | 87 |  */ | 
 | 88 | static int diag_get_dev_info(u16 devno, struct senseid *ps) | 
 | 89 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | 	struct diag210 diag_data; | 
| Peter Oberparleiter | 6f52ac2 | 2008-02-05 16:50:33 +0100 | [diff] [blame] | 91 | 	int ccode; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 |  | 
 | 93 | 	CIO_TRACE_EVENT (4, "VMvdinf"); | 
 | 94 |  | 
 | 95 | 	diag_data = (struct diag210) { | 
 | 96 | 		.vrdcdvno = devno, | 
 | 97 | 		.vrdclen = sizeof (diag_data), | 
 | 98 | 	}; | 
 | 99 |  | 
 | 100 | 	ccode = diag210 (&diag_data); | 
| Peter Oberparleiter | 6f52ac2 | 2008-02-05 16:50:33 +0100 | [diff] [blame] | 101 | 	if ((ccode == 0) || (ccode == 2)) { | 
 | 102 | 		ps->reserved = 0xff; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 |  | 
| Peter Oberparleiter | 6f52ac2 | 2008-02-05 16:50:33 +0100 | [diff] [blame] | 104 | 		/* Special case for osa devices. */ | 
 | 105 | 		if (diag_data.vrdcvcla == 0x02 && diag_data.vrdcvtyp == 0x20) { | 
 | 106 | 			ps->cu_type = 0x3088; | 
 | 107 | 			ps->cu_model = 0x60; | 
 | 108 | 			return 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | 		} | 
| Peter Oberparleiter | 6f52ac2 | 2008-02-05 16:50:33 +0100 | [diff] [blame] | 110 | 		ps->cu_type = vm_vdev_to_cu_type(diag_data.vrdcvcla, | 
 | 111 | 						diag_data.vrdcvtyp); | 
 | 112 | 		if (ps->cu_type != 0xffff) | 
 | 113 | 			return 0; | 
 | 114 | 	} | 
 | 115 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | 	CIO_MSG_EVENT(0, "DIAG X'210' for device %04X returned (cc = %d):" | 
 | 117 | 		      "vdev class : %02X, vdev type : %04X \n ...  " | 
 | 118 | 		      "rdev class : %02X, rdev type : %04X, " | 
 | 119 | 		      "rdev model: %02X\n", | 
 | 120 | 		      devno, ccode, | 
 | 121 | 		      diag_data.vrdcvcla, diag_data.vrdcvtyp, | 
 | 122 | 		      diag_data.vrdcrccl, diag_data.vrdccrty, | 
 | 123 | 		      diag_data.vrdccrmd); | 
| Peter Oberparleiter | 6f52ac2 | 2008-02-05 16:50:33 +0100 | [diff] [blame] | 124 |  | 
 | 125 | 	return -ENODEV; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | } | 
 | 127 |  | 
 | 128 | /* | 
 | 129 |  * Start Sense ID helper function. | 
 | 130 |  * Try to obtain the 'control unit'/'device type' information | 
 | 131 |  *  associated with the subchannel. | 
 | 132 |  */ | 
 | 133 | static int | 
 | 134 | __ccw_device_sense_id_start(struct ccw_device *cdev) | 
 | 135 | { | 
 | 136 | 	struct subchannel *sch; | 
 | 137 | 	struct ccw1 *ccw; | 
| Cornelia Huck | c94dec9 | 2007-12-04 16:09:01 +0100 | [diff] [blame] | 138 | 	int ret; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 |  | 
 | 140 | 	sch = to_subchannel(cdev->dev.parent); | 
 | 141 | 	/* Setup sense channel program. */ | 
 | 142 | 	ccw = cdev->private->iccws; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | 	ccw->cmd_code = CCW_CMD_SENSE_ID; | 
 | 144 | 	ccw->cda = (__u32) __pa (&cdev->private->senseid); | 
 | 145 | 	ccw->count = sizeof (struct senseid); | 
 | 146 | 	ccw->flags = CCW_FLAG_SLI; | 
 | 147 |  | 
 | 148 | 	/* Reset device status. */ | 
 | 149 | 	memset(&cdev->private->irb, 0, sizeof(struct irb)); | 
 | 150 |  | 
| Cornelia Huck | c94dec9 | 2007-12-04 16:09:01 +0100 | [diff] [blame] | 151 | 	/* Try on every path. */ | 
 | 152 | 	ret = -ENODEV; | 
 | 153 | 	while (cdev->private->imask != 0) { | 
| Peter Oberparleiter | 6f52ac2 | 2008-02-05 16:50:33 +0100 | [diff] [blame] | 154 | 		cdev->private->senseid.cu_type = 0xFFFF; | 
| Cornelia Huck | c94dec9 | 2007-12-04 16:09:01 +0100 | [diff] [blame] | 155 | 		if ((sch->opm & cdev->private->imask) != 0 && | 
 | 156 | 		    cdev->private->iretry > 0) { | 
 | 157 | 			cdev->private->iretry--; | 
 | 158 | 			/* Reset internal retry indication. */ | 
 | 159 | 			cdev->private->flags.intretry = 0; | 
 | 160 | 			ret = cio_start (sch, cdev->private->iccws, | 
 | 161 | 					 cdev->private->imask); | 
 | 162 | 			/* ret is 0, -EBUSY, -EACCES or -ENODEV */ | 
 | 163 | 			if (ret != -EACCES) | 
 | 164 | 				return ret; | 
 | 165 | 		} | 
 | 166 | 		cdev->private->imask >>= 1; | 
 | 167 | 		cdev->private->iretry = 5; | 
 | 168 | 	} | 
 | 169 | 	return ret; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | } | 
 | 171 |  | 
 | 172 | void | 
 | 173 | ccw_device_sense_id_start(struct ccw_device *cdev) | 
 | 174 | { | 
 | 175 | 	int ret; | 
 | 176 |  | 
 | 177 | 	memset (&cdev->private->senseid, 0, sizeof (struct senseid)); | 
| Cornelia Huck | c94dec9 | 2007-12-04 16:09:01 +0100 | [diff] [blame] | 178 | 	cdev->private->imask = 0x80; | 
 | 179 | 	cdev->private->iretry = 5; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | 	ret = __ccw_device_sense_id_start(cdev); | 
 | 181 | 	if (ret && ret != -EBUSY) | 
 | 182 | 		ccw_device_sense_id_done(cdev, ret); | 
 | 183 | } | 
 | 184 |  | 
 | 185 | /* | 
 | 186 |  * Called from interrupt context to check if a valid answer | 
 | 187 |  * to Sense ID was received. | 
 | 188 |  */ | 
 | 189 | static int | 
 | 190 | ccw_device_check_sense_id(struct ccw_device *cdev) | 
 | 191 | { | 
 | 192 | 	struct subchannel *sch; | 
 | 193 | 	struct irb *irb; | 
 | 194 |  | 
 | 195 | 	sch = to_subchannel(cdev->dev.parent); | 
 | 196 | 	irb = &cdev->private->irb; | 
| Peter Oberparleiter | 6f52ac2 | 2008-02-05 16:50:33 +0100 | [diff] [blame] | 197 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | 	/* Check the error cases. */ | 
| Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame] | 199 | 	if (irb->scsw.cmd.fctl & (SCSW_FCTL_HALT_FUNC | SCSW_FCTL_CLEAR_FUNC)) { | 
| Cornelia Huck | d23861f | 2006-12-04 15:41:04 +0100 | [diff] [blame] | 200 | 		/* Retry Sense ID if requested. */ | 
 | 201 | 		if (cdev->private->flags.intretry) { | 
 | 202 | 			cdev->private->flags.intretry = 0; | 
 | 203 | 			return -EAGAIN; | 
 | 204 | 		} | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | 		return -ETIME; | 
| Cornelia Huck | d23861f | 2006-12-04 15:41:04 +0100 | [diff] [blame] | 206 | 	} | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | 	if (irb->esw.esw0.erw.cons && (irb->ecw[0] & SNS0_CMD_REJECT)) { | 
 | 208 | 		/* | 
 | 209 | 		 * if the device doesn't support the SenseID | 
 | 210 | 		 *  command further retries wouldn't help ... | 
 | 211 | 		 * NB: We don't check here for intervention required like we | 
 | 212 | 		 *     did before, because tape devices with no tape inserted | 
 | 213 | 		 *     may present this status *in conjunction with* the | 
 | 214 | 		 *     sense id information. So, for intervention required, | 
 | 215 | 		 *     we use the "whack it until it talks" strategy... | 
 | 216 | 		 */ | 
| Michael Ernst | 139b83d | 2008-05-07 09:22:54 +0200 | [diff] [blame] | 217 | 		CIO_MSG_EVENT(0, "SenseID : device %04x on Subchannel " | 
| Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 218 | 			      "0.%x.%04x reports cmd reject\n", | 
| Cornelia Huck | 7896426 | 2006-10-11 15:31:38 +0200 | [diff] [blame] | 219 | 			      cdev->private->dev_id.devno, sch->schid.ssid, | 
| Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 220 | 			      sch->schid.sch_no); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | 		return -EOPNOTSUPP; | 
 | 222 | 	} | 
 | 223 | 	if (irb->esw.esw0.erw.cons) { | 
| Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 224 | 		CIO_MSG_EVENT(2, "SenseID : UC on dev 0.%x.%04x, " | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | 			      "lpum %02X, cnt %02d, sns :" | 
 | 226 | 			      " %02X%02X%02X%02X %02X%02X%02X%02X ...\n", | 
| Cornelia Huck | 7896426 | 2006-10-11 15:31:38 +0200 | [diff] [blame] | 227 | 			      cdev->private->dev_id.ssid, | 
 | 228 | 			      cdev->private->dev_id.devno, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | 			      irb->esw.esw0.sublog.lpum, | 
 | 230 | 			      irb->esw.esw0.erw.scnt, | 
 | 231 | 			      irb->ecw[0], irb->ecw[1], | 
 | 232 | 			      irb->ecw[2], irb->ecw[3], | 
 | 233 | 			      irb->ecw[4], irb->ecw[5], | 
 | 234 | 			      irb->ecw[6], irb->ecw[7]); | 
 | 235 | 		return -EAGAIN; | 
 | 236 | 	} | 
| Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame] | 237 | 	if (irb->scsw.cmd.cc == 3) { | 
| Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 238 | 		u8 lpm; | 
 | 239 |  | 
| Peter Oberparleiter | 83262d6 | 2008-07-14 09:58:51 +0200 | [diff] [blame] | 240 | 		lpm = to_io_private(sch)->orb.cmd.lpm; | 
| Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 241 | 		if ((lpm & sch->schib.pmcw.pim & sch->schib.pmcw.pam) != 0) | 
| Michael Ernst | 139b83d | 2008-05-07 09:22:54 +0200 | [diff] [blame] | 242 | 			CIO_MSG_EVENT(4, "SenseID : path %02X for device %04x " | 
| Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 243 | 				      "on subchannel 0.%x.%04x is " | 
| Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 244 | 				      "'not operational'\n", lpm, | 
| Cornelia Huck | 7896426 | 2006-10-11 15:31:38 +0200 | [diff] [blame] | 245 | 				      cdev->private->dev_id.devno, | 
 | 246 | 				      sch->schid.ssid, sch->schid.sch_no); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | 		return -EACCES; | 
 | 248 | 	} | 
| Peter Oberparleiter | 6f52ac2 | 2008-02-05 16:50:33 +0100 | [diff] [blame] | 249 |  | 
 | 250 | 	/* Did we get a proper answer ? */ | 
| Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame] | 251 | 	if (irb->scsw.cmd.cc == 0 && cdev->private->senseid.cu_type != 0xFFFF && | 
| Peter Oberparleiter | 6f52ac2 | 2008-02-05 16:50:33 +0100 | [diff] [blame] | 252 | 	    cdev->private->senseid.reserved == 0xFF) { | 
| Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame] | 253 | 		if (irb->scsw.cmd.count < sizeof(struct senseid) - 8) | 
| Peter Oberparleiter | 6f52ac2 | 2008-02-05 16:50:33 +0100 | [diff] [blame] | 254 | 			cdev->private->flags.esid = 1; | 
 | 255 | 		return 0; /* Success */ | 
 | 256 | 	} | 
 | 257 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | 	/* Hmm, whatever happened, try again. */ | 
 | 259 | 	CIO_MSG_EVENT(2, "SenseID : start_IO() for device %04x on " | 
| Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 260 | 		      "subchannel 0.%x.%04x returns status %02X%02X\n", | 
| Cornelia Huck | 7896426 | 2006-10-11 15:31:38 +0200 | [diff] [blame] | 261 | 		      cdev->private->dev_id.devno, sch->schid.ssid, | 
 | 262 | 		      sch->schid.sch_no, | 
| Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame] | 263 | 		      irb->scsw.cmd.dstat, irb->scsw.cmd.cstat); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | 	return -EAGAIN; | 
 | 265 | } | 
 | 266 |  | 
 | 267 | /* | 
 | 268 |  * Got interrupt for Sense ID. | 
 | 269 |  */ | 
 | 270 | void | 
 | 271 | ccw_device_sense_id_irq(struct ccw_device *cdev, enum dev_event dev_event) | 
 | 272 | { | 
 | 273 | 	struct subchannel *sch; | 
 | 274 | 	struct irb *irb; | 
 | 275 | 	int ret; | 
 | 276 |  | 
 | 277 | 	sch = to_subchannel(cdev->dev.parent); | 
 | 278 | 	irb = (struct irb *) __LC_IRB; | 
 | 279 | 	/* Retry sense id, if needed. */ | 
| Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame] | 280 | 	if (irb->scsw.cmd.stctl == | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | 	    (SCSW_STCTL_STATUS_PEND | SCSW_STCTL_ALERT_STATUS)) { | 
| Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame] | 282 | 		if ((irb->scsw.cmd.cc == 1) || !irb->scsw.cmd.actl) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | 			ret = __ccw_device_sense_id_start(cdev); | 
 | 284 | 			if (ret && ret != -EBUSY) | 
 | 285 | 				ccw_device_sense_id_done(cdev, ret); | 
 | 286 | 		} | 
 | 287 | 		return; | 
 | 288 | 	} | 
 | 289 | 	if (ccw_device_accumulate_and_sense(cdev, irb) != 0) | 
 | 290 | 		return; | 
 | 291 | 	ret = ccw_device_check_sense_id(cdev); | 
 | 292 | 	memset(&cdev->private->irb, 0, sizeof(struct irb)); | 
 | 293 | 	switch (ret) { | 
 | 294 | 	/* 0, -ETIME, -EOPNOTSUPP, -EAGAIN or -EACCES */ | 
 | 295 | 	case 0:			/* Sense id succeeded. */ | 
 | 296 | 	case -ETIME:		/* Sense id stopped by timeout. */ | 
 | 297 | 		ccw_device_sense_id_done(cdev, ret); | 
 | 298 | 		break; | 
 | 299 | 	case -EACCES:		/* channel is not operational. */ | 
| Cornelia Huck | c94dec9 | 2007-12-04 16:09:01 +0100 | [diff] [blame] | 300 | 		sch->lpm &= ~cdev->private->imask; | 
 | 301 | 		cdev->private->imask >>= 1; | 
 | 302 | 		cdev->private->iretry = 5; | 
 | 303 | 		/* fall through. */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | 	case -EAGAIN:		/* try again. */ | 
| Cornelia Huck | c94dec9 | 2007-12-04 16:09:01 +0100 | [diff] [blame] | 305 | 		ret = __ccw_device_sense_id_start(cdev); | 
 | 306 | 		if (ret == 0 || ret == -EBUSY) | 
 | 307 | 			break; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | 		/* fall through. */ | 
 | 309 | 	default:		/* Sense ID failed. Try asking VM. */ | 
| Peter Oberparleiter | 6f52ac2 | 2008-02-05 16:50:33 +0100 | [diff] [blame] | 310 | 		if (MACHINE_IS_VM) | 
 | 311 | 			ret = diag_get_dev_info(cdev->private->dev_id.devno, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | 						&cdev->private->senseid); | 
| Peter Oberparleiter | 6f52ac2 | 2008-02-05 16:50:33 +0100 | [diff] [blame] | 313 | 		else | 
 | 314 | 			/* | 
 | 315 | 			 * If we can't couldn't identify the device type we | 
 | 316 | 			 *  consider the device "not operational". | 
 | 317 | 			 */ | 
 | 318 | 			ret = -ENODEV; | 
 | 319 |  | 
 | 320 | 		ccw_device_sense_id_done(cdev, ret); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | 		break; | 
 | 322 | 	} | 
 | 323 | } |