xref: /linux/drivers/s390/cio/device_id.c (revision d23861ff1a4da1f4a5255eb4582f620191c6e1c0)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  * drivers/s390/cio/device_id.c
31da177e4SLinus Torvalds  *
41da177e4SLinus Torvalds  *    Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
51da177e4SLinus Torvalds  *			 IBM Corporation
64ce3b30cSCornelia Huck  *    Author(s): Cornelia Huck (cornelia.huck@de.ibm.com)
71da177e4SLinus Torvalds  *		 Martin Schwidefsky (schwidefsky@de.ibm.com)
81da177e4SLinus Torvalds  *
91da177e4SLinus Torvalds  * Sense ID functions.
101da177e4SLinus Torvalds  */
111da177e4SLinus Torvalds 
121da177e4SLinus Torvalds #include <linux/module.h>
131da177e4SLinus Torvalds #include <linux/init.h>
141da177e4SLinus Torvalds 
151da177e4SLinus Torvalds #include <asm/ccwdev.h>
161da177e4SLinus Torvalds #include <asm/delay.h>
171da177e4SLinus Torvalds #include <asm/cio.h>
181da177e4SLinus Torvalds #include <asm/lowcore.h>
191da177e4SLinus Torvalds 
201da177e4SLinus Torvalds #include "cio.h"
211da177e4SLinus Torvalds #include "cio_debug.h"
221da177e4SLinus Torvalds #include "css.h"
231da177e4SLinus Torvalds #include "device.h"
241da177e4SLinus Torvalds #include "ioasm.h"
251da177e4SLinus Torvalds 
261da177e4SLinus Torvalds /*
271da177e4SLinus Torvalds  * diag210 is used under VM to get information about a virtual device
281da177e4SLinus Torvalds  */
29347a8dc3SMartin Schwidefsky #ifdef CONFIG_64BIT
301da177e4SLinus Torvalds int
311da177e4SLinus Torvalds diag210(struct diag210 * addr)
321da177e4SLinus Torvalds {
331da177e4SLinus Torvalds 	/*
341da177e4SLinus Torvalds 	 * diag 210 needs its data below the 2GB border, so we
351da177e4SLinus Torvalds 	 * use a static data area to be sure
361da177e4SLinus Torvalds 	 */
371da177e4SLinus Torvalds 	static struct diag210 diag210_tmp;
381da177e4SLinus Torvalds 	static DEFINE_SPINLOCK(diag210_lock);
391da177e4SLinus Torvalds 	unsigned long flags;
401da177e4SLinus Torvalds 	int ccode;
411da177e4SLinus Torvalds 
421da177e4SLinus Torvalds 	spin_lock_irqsave(&diag210_lock, flags);
431da177e4SLinus Torvalds 	diag210_tmp = *addr;
441da177e4SLinus Torvalds 
451da177e4SLinus Torvalds 	asm volatile(
461da177e4SLinus Torvalds 		"	lhi	%0,-1\n"
471da177e4SLinus Torvalds 		"	sam31\n"
481da177e4SLinus Torvalds 		"	diag	%1,0,0x210\n"
491da177e4SLinus Torvalds 		"0:	ipm	%0\n"
501da177e4SLinus Torvalds 		"	srl	%0,28\n"
511da177e4SLinus Torvalds 		"1:	sam64\n"
5294c12cc7SMartin Schwidefsky 		EX_TABLE(0b,1b)
531da177e4SLinus Torvalds 		: "=&d" (ccode) : "a" (__pa(&diag210_tmp)) : "cc", "memory");
541da177e4SLinus Torvalds 
551da177e4SLinus Torvalds 	*addr = diag210_tmp;
561da177e4SLinus Torvalds 	spin_unlock_irqrestore(&diag210_lock, flags);
571da177e4SLinus Torvalds 
581da177e4SLinus Torvalds 	return ccode;
591da177e4SLinus Torvalds }
601da177e4SLinus Torvalds #else
611da177e4SLinus Torvalds int
621da177e4SLinus Torvalds diag210(struct diag210 * addr)
631da177e4SLinus Torvalds {
641da177e4SLinus Torvalds 	int ccode;
651da177e4SLinus Torvalds 
661da177e4SLinus Torvalds 	asm volatile(
671da177e4SLinus Torvalds 		"	lhi	%0,-1\n"
681da177e4SLinus Torvalds 		"	diag	%1,0,0x210\n"
691da177e4SLinus Torvalds 		"0:	ipm	%0\n"
701da177e4SLinus Torvalds 		"	srl	%0,28\n"
711da177e4SLinus Torvalds 		"1:\n"
7294c12cc7SMartin Schwidefsky 		EX_TABLE(0b,1b)
731da177e4SLinus Torvalds 		: "=&d" (ccode) : "a" (__pa(addr)) : "cc", "memory");
741da177e4SLinus Torvalds 
751da177e4SLinus Torvalds 	return ccode;
761da177e4SLinus Torvalds }
771da177e4SLinus Torvalds #endif
781da177e4SLinus Torvalds 
791da177e4SLinus Torvalds /*
801da177e4SLinus Torvalds  * Input :
811da177e4SLinus Torvalds  *   devno - device number
821da177e4SLinus Torvalds  *   ps	   - pointer to sense ID data area
831da177e4SLinus Torvalds  * Output : none
841da177e4SLinus Torvalds  */
851da177e4SLinus Torvalds static void
861da177e4SLinus Torvalds VM_virtual_device_info (__u16 devno, struct senseid *ps)
871da177e4SLinus Torvalds {
881da177e4SLinus Torvalds 	static struct {
891da177e4SLinus Torvalds 		int vrdcvcla, vrdcvtyp, cu_type;
901da177e4SLinus Torvalds 	} vm_devices[] = {
911da177e4SLinus Torvalds 		{ 0x08, 0x01, 0x3480 },
921da177e4SLinus Torvalds 		{ 0x08, 0x02, 0x3430 },
931da177e4SLinus Torvalds 		{ 0x08, 0x10, 0x3420 },
941da177e4SLinus Torvalds 		{ 0x08, 0x42, 0x3424 },
951da177e4SLinus Torvalds 		{ 0x08, 0x44, 0x9348 },
961da177e4SLinus Torvalds 		{ 0x08, 0x81, 0x3490 },
971da177e4SLinus Torvalds 		{ 0x08, 0x82, 0x3422 },
981da177e4SLinus Torvalds 		{ 0x10, 0x41, 0x1403 },
991da177e4SLinus Torvalds 		{ 0x10, 0x42, 0x3211 },
1001da177e4SLinus Torvalds 		{ 0x10, 0x43, 0x3203 },
1011da177e4SLinus Torvalds 		{ 0x10, 0x45, 0x3800 },
1021da177e4SLinus Torvalds 		{ 0x10, 0x47, 0x3262 },
1031da177e4SLinus Torvalds 		{ 0x10, 0x48, 0x3820 },
1041da177e4SLinus Torvalds 		{ 0x10, 0x49, 0x3800 },
1051da177e4SLinus Torvalds 		{ 0x10, 0x4a, 0x4245 },
1061da177e4SLinus Torvalds 		{ 0x10, 0x4b, 0x4248 },
1071da177e4SLinus Torvalds 		{ 0x10, 0x4d, 0x3800 },
1081da177e4SLinus Torvalds 		{ 0x10, 0x4e, 0x3820 },
1091da177e4SLinus Torvalds 		{ 0x10, 0x4f, 0x3820 },
1101da177e4SLinus Torvalds 		{ 0x10, 0x82, 0x2540 },
1111da177e4SLinus Torvalds 		{ 0x10, 0x84, 0x3525 },
1121da177e4SLinus Torvalds 		{ 0x20, 0x81, 0x2501 },
1131da177e4SLinus Torvalds 		{ 0x20, 0x82, 0x2540 },
1141da177e4SLinus Torvalds 		{ 0x20, 0x84, 0x3505 },
1151da177e4SLinus Torvalds 		{ 0x40, 0x01, 0x3278 },
1161da177e4SLinus Torvalds 		{ 0x40, 0x04, 0x3277 },
1171da177e4SLinus Torvalds 		{ 0x40, 0x80, 0x2250 },
1181da177e4SLinus Torvalds 		{ 0x40, 0xc0, 0x5080 },
1191da177e4SLinus Torvalds 		{ 0x80, 0x00, 0x3215 },
1201da177e4SLinus Torvalds 	};
1211da177e4SLinus Torvalds 	struct diag210 diag_data;
1221da177e4SLinus Torvalds 	int ccode, i;
1231da177e4SLinus Torvalds 
1241da177e4SLinus Torvalds 	CIO_TRACE_EVENT (4, "VMvdinf");
1251da177e4SLinus Torvalds 
1261da177e4SLinus Torvalds 	diag_data = (struct diag210) {
1271da177e4SLinus Torvalds 		.vrdcdvno = devno,
1281da177e4SLinus Torvalds 		.vrdclen = sizeof (diag_data),
1291da177e4SLinus Torvalds 	};
1301da177e4SLinus Torvalds 
1311da177e4SLinus Torvalds 	ccode = diag210 (&diag_data);
1321da177e4SLinus Torvalds 	ps->reserved = 0xff;
1331da177e4SLinus Torvalds 
1341da177e4SLinus Torvalds 	/* Special case for bloody osa devices. */
1351da177e4SLinus Torvalds 	if (diag_data.vrdcvcla == 0x02 &&
1361da177e4SLinus Torvalds 	    diag_data.vrdcvtyp == 0x20) {
1371da177e4SLinus Torvalds 		ps->cu_type = 0x3088;
1381da177e4SLinus Torvalds 		ps->cu_model = 0x60;
1391da177e4SLinus Torvalds 		return;
1401da177e4SLinus Torvalds 	}
1411da177e4SLinus Torvalds 	for (i = 0; i < sizeof(vm_devices) / sizeof(vm_devices[0]); i++)
1421da177e4SLinus Torvalds 		if (diag_data.vrdcvcla == vm_devices[i].vrdcvcla &&
1431da177e4SLinus Torvalds 		    diag_data.vrdcvtyp == vm_devices[i].vrdcvtyp) {
1441da177e4SLinus Torvalds 			ps->cu_type = vm_devices[i].cu_type;
1451da177e4SLinus Torvalds 			return;
1461da177e4SLinus Torvalds 		}
1471da177e4SLinus Torvalds 	CIO_MSG_EVENT(0, "DIAG X'210' for device %04X returned (cc = %d):"
1481da177e4SLinus Torvalds 		      "vdev class : %02X, vdev type : %04X \n ...  "
1491da177e4SLinus Torvalds 		      "rdev class : %02X, rdev type : %04X, "
1501da177e4SLinus Torvalds 		      "rdev model: %02X\n",
1511da177e4SLinus Torvalds 		      devno, ccode,
1521da177e4SLinus Torvalds 		      diag_data.vrdcvcla, diag_data.vrdcvtyp,
1531da177e4SLinus Torvalds 		      diag_data.vrdcrccl, diag_data.vrdccrty,
1541da177e4SLinus Torvalds 		      diag_data.vrdccrmd);
1551da177e4SLinus Torvalds }
1561da177e4SLinus Torvalds 
1571da177e4SLinus Torvalds /*
1581da177e4SLinus Torvalds  * Start Sense ID helper function.
1591da177e4SLinus Torvalds  * Try to obtain the 'control unit'/'device type' information
1601da177e4SLinus Torvalds  *  associated with the subchannel.
1611da177e4SLinus Torvalds  */
1621da177e4SLinus Torvalds static int
1631da177e4SLinus Torvalds __ccw_device_sense_id_start(struct ccw_device *cdev)
1641da177e4SLinus Torvalds {
1651da177e4SLinus Torvalds 	struct subchannel *sch;
1661da177e4SLinus Torvalds 	struct ccw1 *ccw;
1671da177e4SLinus Torvalds 	int ret;
1681da177e4SLinus Torvalds 
1691da177e4SLinus Torvalds 	sch = to_subchannel(cdev->dev.parent);
1701da177e4SLinus Torvalds 	/* Setup sense channel program. */
1711da177e4SLinus Torvalds 	ccw = cdev->private->iccws;
1721da177e4SLinus Torvalds 	if (sch->schib.pmcw.pim != 0x80) {
1731da177e4SLinus Torvalds 		/* more than one path installed. */
1741da177e4SLinus Torvalds 		ccw->cmd_code = CCW_CMD_SUSPEND_RECONN;
1751da177e4SLinus Torvalds 		ccw->cda = 0;
1761da177e4SLinus Torvalds 		ccw->count = 0;
1771da177e4SLinus Torvalds 		ccw->flags = CCW_FLAG_SLI | CCW_FLAG_CC;
1781da177e4SLinus Torvalds 		ccw++;
1791da177e4SLinus Torvalds 	}
1801da177e4SLinus Torvalds 	ccw->cmd_code = CCW_CMD_SENSE_ID;
1811da177e4SLinus Torvalds 	ccw->cda = (__u32) __pa (&cdev->private->senseid);
1821da177e4SLinus Torvalds 	ccw->count = sizeof (struct senseid);
1831da177e4SLinus Torvalds 	ccw->flags = CCW_FLAG_SLI;
1841da177e4SLinus Torvalds 
1851da177e4SLinus Torvalds 	/* Reset device status. */
1861da177e4SLinus Torvalds 	memset(&cdev->private->irb, 0, sizeof(struct irb));
1871da177e4SLinus Torvalds 
1881da177e4SLinus Torvalds 	/* Try on every path. */
1891da177e4SLinus Torvalds 	ret = -ENODEV;
1901da177e4SLinus Torvalds 	while (cdev->private->imask != 0) {
1911da177e4SLinus Torvalds 		if ((sch->opm & cdev->private->imask) != 0 &&
1921da177e4SLinus Torvalds 		    cdev->private->iretry > 0) {
1931da177e4SLinus Torvalds 			cdev->private->iretry--;
194*d23861ffSCornelia Huck 			/* Reset internal retry indication. */
195*d23861ffSCornelia Huck 			cdev->private->flags.intretry = 0;
1961da177e4SLinus Torvalds 			ret = cio_start (sch, cdev->private->iccws,
1971da177e4SLinus Torvalds 					 cdev->private->imask);
1981da177e4SLinus Torvalds 			/* ret is 0, -EBUSY, -EACCES or -ENODEV */
1991da177e4SLinus Torvalds 			if (ret != -EACCES)
2001da177e4SLinus Torvalds 				return ret;
2011da177e4SLinus Torvalds 		}
2021da177e4SLinus Torvalds 		cdev->private->imask >>= 1;
2031da177e4SLinus Torvalds 		cdev->private->iretry = 5;
2041da177e4SLinus Torvalds 	}
2051da177e4SLinus Torvalds 	return ret;
2061da177e4SLinus Torvalds }
2071da177e4SLinus Torvalds 
2081da177e4SLinus Torvalds void
2091da177e4SLinus Torvalds ccw_device_sense_id_start(struct ccw_device *cdev)
2101da177e4SLinus Torvalds {
2111da177e4SLinus Torvalds 	int ret;
2121da177e4SLinus Torvalds 
2131da177e4SLinus Torvalds 	memset (&cdev->private->senseid, 0, sizeof (struct senseid));
2141da177e4SLinus Torvalds 	cdev->private->senseid.cu_type = 0xFFFF;
2151da177e4SLinus Torvalds 	cdev->private->imask = 0x80;
2161da177e4SLinus Torvalds 	cdev->private->iretry = 5;
2171da177e4SLinus Torvalds 	ret = __ccw_device_sense_id_start(cdev);
2181da177e4SLinus Torvalds 	if (ret && ret != -EBUSY)
2191da177e4SLinus Torvalds 		ccw_device_sense_id_done(cdev, ret);
2201da177e4SLinus Torvalds }
2211da177e4SLinus Torvalds 
2221da177e4SLinus Torvalds /*
2231da177e4SLinus Torvalds  * Called from interrupt context to check if a valid answer
2241da177e4SLinus Torvalds  * to Sense ID was received.
2251da177e4SLinus Torvalds  */
2261da177e4SLinus Torvalds static int
2271da177e4SLinus Torvalds ccw_device_check_sense_id(struct ccw_device *cdev)
2281da177e4SLinus Torvalds {
2291da177e4SLinus Torvalds 	struct subchannel *sch;
2301da177e4SLinus Torvalds 	struct irb *irb;
2311da177e4SLinus Torvalds 
2321da177e4SLinus Torvalds 	sch = to_subchannel(cdev->dev.parent);
2331da177e4SLinus Torvalds 	irb = &cdev->private->irb;
2341da177e4SLinus Torvalds 	/* Did we get a proper answer ? */
2351da177e4SLinus Torvalds 	if (cdev->private->senseid.cu_type != 0xFFFF &&
2361da177e4SLinus Torvalds 	    cdev->private->senseid.reserved == 0xFF) {
2371da177e4SLinus Torvalds 		if (irb->scsw.count < sizeof (struct senseid) - 8)
2381da177e4SLinus Torvalds 			cdev->private->flags.esid = 1;
2391da177e4SLinus Torvalds 		return 0; /* Success */
2401da177e4SLinus Torvalds 	}
2411da177e4SLinus Torvalds 	/* Check the error cases. */
242*d23861ffSCornelia Huck 	if (irb->scsw.fctl & (SCSW_FCTL_HALT_FUNC | SCSW_FCTL_CLEAR_FUNC)) {
243*d23861ffSCornelia Huck 		/* Retry Sense ID if requested. */
244*d23861ffSCornelia Huck 		if (cdev->private->flags.intretry) {
245*d23861ffSCornelia Huck 			cdev->private->flags.intretry = 0;
246*d23861ffSCornelia Huck 			return -EAGAIN;
247*d23861ffSCornelia Huck 		}
2481da177e4SLinus Torvalds 		return -ETIME;
249*d23861ffSCornelia Huck 	}
2501da177e4SLinus Torvalds 	if (irb->esw.esw0.erw.cons && (irb->ecw[0] & SNS0_CMD_REJECT)) {
2511da177e4SLinus Torvalds 		/*
2521da177e4SLinus Torvalds 		 * if the device doesn't support the SenseID
2531da177e4SLinus Torvalds 		 *  command further retries wouldn't help ...
2541da177e4SLinus Torvalds 		 * NB: We don't check here for intervention required like we
2551da177e4SLinus Torvalds 		 *     did before, because tape devices with no tape inserted
2561da177e4SLinus Torvalds 		 *     may present this status *in conjunction with* the
2571da177e4SLinus Torvalds 		 *     sense id information. So, for intervention required,
2581da177e4SLinus Torvalds 		 *     we use the "whack it until it talks" strategy...
2591da177e4SLinus Torvalds 		 */
260fb6958a5SCornelia Huck 		CIO_MSG_EVENT(2, "SenseID : device %04x on Subchannel "
261fb6958a5SCornelia Huck 			      "0.%x.%04x reports cmd reject\n",
26278964268SCornelia Huck 			      cdev->private->dev_id.devno, sch->schid.ssid,
263fb6958a5SCornelia Huck 			      sch->schid.sch_no);
2641da177e4SLinus Torvalds 		return -EOPNOTSUPP;
2651da177e4SLinus Torvalds 	}
2661da177e4SLinus Torvalds 	if (irb->esw.esw0.erw.cons) {
267fb6958a5SCornelia Huck 		CIO_MSG_EVENT(2, "SenseID : UC on dev 0.%x.%04x, "
2681da177e4SLinus Torvalds 			      "lpum %02X, cnt %02d, sns :"
2691da177e4SLinus Torvalds 			      " %02X%02X%02X%02X %02X%02X%02X%02X ...\n",
27078964268SCornelia Huck 			      cdev->private->dev_id.ssid,
27178964268SCornelia Huck 			      cdev->private->dev_id.devno,
2721da177e4SLinus Torvalds 			      irb->esw.esw0.sublog.lpum,
2731da177e4SLinus Torvalds 			      irb->esw.esw0.erw.scnt,
2741da177e4SLinus Torvalds 			      irb->ecw[0], irb->ecw[1],
2751da177e4SLinus Torvalds 			      irb->ecw[2], irb->ecw[3],
2761da177e4SLinus Torvalds 			      irb->ecw[4], irb->ecw[5],
2771da177e4SLinus Torvalds 			      irb->ecw[6], irb->ecw[7]);
2781da177e4SLinus Torvalds 		return -EAGAIN;
2791da177e4SLinus Torvalds 	}
2801da177e4SLinus Torvalds 	if (irb->scsw.cc == 3) {
2811da177e4SLinus Torvalds 		if ((sch->orb.lpm &
2821da177e4SLinus Torvalds 		     sch->schib.pmcw.pim & sch->schib.pmcw.pam) != 0)
283fb6958a5SCornelia Huck 			CIO_MSG_EVENT(2, "SenseID : path %02X for device %04x "
284fb6958a5SCornelia Huck 				      "on subchannel 0.%x.%04x is "
285fb6958a5SCornelia Huck 				      "'not operational'\n", sch->orb.lpm,
28678964268SCornelia Huck 				      cdev->private->dev_id.devno,
28778964268SCornelia Huck 				      sch->schid.ssid, sch->schid.sch_no);
2881da177e4SLinus Torvalds 		return -EACCES;
2891da177e4SLinus Torvalds 	}
2901da177e4SLinus Torvalds 	/* Hmm, whatever happened, try again. */
2911da177e4SLinus Torvalds 	CIO_MSG_EVENT(2, "SenseID : start_IO() for device %04x on "
292fb6958a5SCornelia Huck 		      "subchannel 0.%x.%04x returns status %02X%02X\n",
29378964268SCornelia Huck 		      cdev->private->dev_id.devno, sch->schid.ssid,
29478964268SCornelia Huck 		      sch->schid.sch_no,
2951da177e4SLinus Torvalds 		      irb->scsw.dstat, irb->scsw.cstat);
2961da177e4SLinus Torvalds 	return -EAGAIN;
2971da177e4SLinus Torvalds }
2981da177e4SLinus Torvalds 
2991da177e4SLinus Torvalds /*
3001da177e4SLinus Torvalds  * Got interrupt for Sense ID.
3011da177e4SLinus Torvalds  */
3021da177e4SLinus Torvalds void
3031da177e4SLinus Torvalds ccw_device_sense_id_irq(struct ccw_device *cdev, enum dev_event dev_event)
3041da177e4SLinus Torvalds {
3051da177e4SLinus Torvalds 	struct subchannel *sch;
3061da177e4SLinus Torvalds 	struct irb *irb;
3071da177e4SLinus Torvalds 	int ret;
3081da177e4SLinus Torvalds 
3091da177e4SLinus Torvalds 	sch = to_subchannel(cdev->dev.parent);
3101da177e4SLinus Torvalds 	irb = (struct irb *) __LC_IRB;
3111da177e4SLinus Torvalds 	/* Retry sense id, if needed. */
3121da177e4SLinus Torvalds 	if (irb->scsw.stctl ==
3131da177e4SLinus Torvalds 	    (SCSW_STCTL_STATUS_PEND | SCSW_STCTL_ALERT_STATUS)) {
3141da177e4SLinus Torvalds 		if ((irb->scsw.cc == 1) || !irb->scsw.actl) {
3151da177e4SLinus Torvalds 			ret = __ccw_device_sense_id_start(cdev);
3161da177e4SLinus Torvalds 			if (ret && ret != -EBUSY)
3171da177e4SLinus Torvalds 				ccw_device_sense_id_done(cdev, ret);
3181da177e4SLinus Torvalds 		}
3191da177e4SLinus Torvalds 		return;
3201da177e4SLinus Torvalds 	}
3211da177e4SLinus Torvalds 	if (ccw_device_accumulate_and_sense(cdev, irb) != 0)
3221da177e4SLinus Torvalds 		return;
3231da177e4SLinus Torvalds 	ret = ccw_device_check_sense_id(cdev);
3241da177e4SLinus Torvalds 	memset(&cdev->private->irb, 0, sizeof(struct irb));
3251da177e4SLinus Torvalds 	switch (ret) {
3261da177e4SLinus Torvalds 	/* 0, -ETIME, -EOPNOTSUPP, -EAGAIN or -EACCES */
3271da177e4SLinus Torvalds 	case 0:			/* Sense id succeeded. */
3281da177e4SLinus Torvalds 	case -ETIME:		/* Sense id stopped by timeout. */
3291da177e4SLinus Torvalds 		ccw_device_sense_id_done(cdev, ret);
3301da177e4SLinus Torvalds 		break;
3311da177e4SLinus Torvalds 	case -EACCES:		/* channel is not operational. */
3321da177e4SLinus Torvalds 		sch->lpm &= ~cdev->private->imask;
3331da177e4SLinus Torvalds 		cdev->private->imask >>= 1;
3341da177e4SLinus Torvalds 		cdev->private->iretry = 5;
3351da177e4SLinus Torvalds 		/* fall through. */
3361da177e4SLinus Torvalds 	case -EAGAIN:		/* try again. */
3371da177e4SLinus Torvalds 		ret = __ccw_device_sense_id_start(cdev);
3381da177e4SLinus Torvalds 		if (ret == 0 || ret == -EBUSY)
3391da177e4SLinus Torvalds 			break;
3401da177e4SLinus Torvalds 		/* fall through. */
3411da177e4SLinus Torvalds 	default:		/* Sense ID failed. Try asking VM. */
3421da177e4SLinus Torvalds 		if (MACHINE_IS_VM) {
34378964268SCornelia Huck 			VM_virtual_device_info (cdev->private->dev_id.devno,
3441da177e4SLinus Torvalds 						&cdev->private->senseid);
3451da177e4SLinus Torvalds 			if (cdev->private->senseid.cu_type != 0xFFFF) {
3461da177e4SLinus Torvalds 				/* Got the device information from VM. */
3471da177e4SLinus Torvalds 				ccw_device_sense_id_done(cdev, 0);
3481da177e4SLinus Torvalds 				return;
3491da177e4SLinus Torvalds 			}
3501da177e4SLinus Torvalds 		}
3511da177e4SLinus Torvalds 		/*
3521da177e4SLinus Torvalds 		 * If we can't couldn't identify the device type we
3531da177e4SLinus Torvalds 		 *  consider the device "not operational".
3541da177e4SLinus Torvalds 		 */
3551da177e4SLinus Torvalds 		ccw_device_sense_id_done(cdev, -ENODEV);
3561da177e4SLinus Torvalds 		break;
3571da177e4SLinus Torvalds 	}
3581da177e4SLinus Torvalds }
3591da177e4SLinus Torvalds 
3601da177e4SLinus Torvalds EXPORT_SYMBOL(diag210);
361