Skip to contentSkip to conversation

s390 (5/8): common i/o layer.

PATCH In review Martin Schwidefsky 3 participants 4 messages Aug 29, 2003

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390 (5/8): common i/o layer.

- Remove initialization of device.name.
- Don't do put_device after failed get_device in get_ccwdev_by_busid.
- Fix read_dev_chars and read_conf_data.
- Call interrupt function of ccw device if path verification has been started.
- Replace atomic_return_add by atomic_add_return in qdio.

diffstat:

 drivers/s390/cio/chsc.c       |    6 +-----
 drivers/s390/cio/css.c        |   17 ++---------------
 drivers/s390/cio/device.c     |    9 +++++----
 drivers/s390/cio/device_ops.c |   37 ++++++++++++++++++++++++-------------
 drivers/s390/cio/qdio.c       |   23 ++++++-----------------
 5 files changed, 38 insertions(+), 54 deletions(-)
drivers/s390/cio/chsc.c +1 -5
diff -urN linux-2.6/drivers/s390/cio/chsc.c linux-2.6-s390/drivers/s390/cio/chsc.c
@@ -1,7 +1,7 @@
 /*
  *  drivers/s390/cio/chsc.c
  *   S/390 common I/O routines -- channel subsystem call
- *   $Revision: 1.74 $
+ *   $Revision: 1.76 $
  *
  *    Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
  *			      IBM Corporation
@@ -865,10 +865,6 @@
 	chp->state = status;
 	chp->dev.parent = &css_bus_device;
 
-	snprintf(chp->dev.name, DEVICE_NAME_SIZE,
-		 "channel path %x", chpid);
-	snprintf(chp->dev.bus_id, DEVICE_ID_SIZE, "chp%x", chpid);
-
 	/* make it known to the system */
 	ret = device_register(&chp->dev);
 	if (ret) {
drivers/s390/cio/css.c +2 -15
diff -urN linux-2.6/drivers/s390/cio/css.c linux-2.6-s390/drivers/s390/cio/css.c
@@ -1,7 +1,7 @@
 /*
  *  drivers/s390/cio/css.c
  *  driver for channel subsystem
- *   $Revision: 1.43 $
+ *   $Revision: 1.48 $
  *
  *    Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
  *			 IBM Corporation
@@ -27,7 +27,6 @@
 int css_init_done = 0;
 
 struct device css_bus_device = {
-	.name	= "Channel Subsystem 0",
 	.bus_id = "css0",
 };
 
@@ -79,17 +78,6 @@
 static int
 css_register_subchannel(struct subchannel *sch)
 {
-	static const char *subchannel_types[] = {
-		"I/O Subchannel",
-		"CHSC Subchannel",
-		"Message Subchannel",
-		"ADM Subchannel",
-		"undefined subchannel type 4",
-		"undefined subchannel type 5",
-		"undefined subchannel type 6",
-		"undefined subchannel type 7",
-		"undefined subchannel type 8",
-	};
 	int ret;
 
 	/* Initialize the subchannel structure */
@@ -97,8 +85,7 @@
 	sch->dev.bus = &css_bus_type;
 
 	/* Set a name for the subchannel */
-	strlcpy (sch->dev.name, subchannel_types[sch->st], DEVICE_NAME_SIZE);
-	snprintf (sch->dev.bus_id, DEVICE_ID_SIZE, "0:%04x", sch->irq);
+	snprintf (sch->dev.bus_id, DEVICE_ID_SIZE, "0.0.%04x", sch->irq);
 
 	/* make it known to the system */
 	ret = device_register(&sch->dev);
drivers/s390/cio/device.c +5 -4
diff -urN linux-2.6/drivers/s390/cio/device.c linux-2.6-s390/drivers/s390/cio/device.c
@@ -1,7 +1,7 @@
 /*
  *  drivers/s390/cio/device.c
  *  bus driver for ccw devices
- *   $Revision: 1.60 $
+ *   $Revision: 1.65 $
  *
  *    Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
  *			 IBM Corporation
@@ -537,8 +537,7 @@
 	init_timer(&cdev->private->timer);
 
 	/* Set an initial name for the device. */
-	snprintf (cdev->dev.name, DEVICE_NAME_SIZE,"ccw device");
-	snprintf (cdev->dev.bus_id, DEVICE_ID_SIZE, "0:%04x",
+	snprintf (cdev->dev.bus_id, DEVICE_ID_SIZE, "0.0.%04x",
 		  sch->schib.pmcw.dev);
 
 	/* Increase counter of devices currently in recognition. */
@@ -704,8 +703,10 @@
 
 		if (dev && !strncmp(bus_id, dev->bus_id, DEVICE_ID_SIZE))
 			break;
-		else
+		else if (dev) {
 			put_device(dev);
+			dev = NULL;
+		}
 	}
 	up_read(&drv->bus->subsys.rwsem);
 	put_driver(drv);
drivers/s390/cio/device_ops.c +24 -13
diff -urN linux-2.6/drivers/s390/cio/device_ops.c linux-2.6-s390/drivers/s390/cio/device_ops.c
@@ -160,13 +160,15 @@
 	 *  - we received an intermediate status
 	 *  - fast notification was requested (primary status)
 	 *  - unsolicited interrupts
+	 *  - device path verification has been started
 	 */
 	stctl = cdev->private->irb.scsw.stctl;
 	if (sch->schib.scsw.actl != 0 &&
 	    !cdev->private->options.repall &&
 	    !(stctl & SCSW_STCTL_INTER_STATUS) &&
 	    !(cdev->private->options.fast &&
-	      (stctl & SCSW_STCTL_PRIM_STATUS)))
+	      (stctl & SCSW_STCTL_PRIM_STATUS)) &&
+	    (cdev->private->state != DEV_STATE_VERIFY))
 		return;
 
 	/*
@@ -211,11 +213,19 @@
 static void
 ccw_device_wake_up(struct ccw_device *cdev, unsigned long ip, struct irb *irb)
 {
-	struct subchannel *sch;
+	if (!ip)
+		/* unsolicited interrupt */
+		return;
 
-	sch = to_subchannel(cdev->dev.parent);
-	if (!IS_ERR(irb))
-		memcpy(&sch->schib.scsw, &irb->scsw, sizeof(struct scsw));
+	/* Abuse intparm for error reporting. */
+	if (IS_ERR(irb))
+		cdev->private->intparm = -EIO;
+	else if ((irb->scsw.dstat !=
+		  (DEV_STAT_CHN_END|DEV_STAT_DEV_END)) ||
+		 (irb->scsw.cstat != 0))
+		cdev->private->intparm = -EIO;
+	else
+		cdev->private->intparm = 0;
 	wake_up(&cdev->private->wait_q);
 }
 
@@ -270,14 +280,14 @@
 			break;
 		if (ret == 0) {
 			/* Wait for end of request. */
+			cdev->private->intparm = 0x00524443;
 			spin_unlock_irqrestore(&sch->lock, flags);
 			wait_event(cdev->private->wait_q,
-				   sch->schib.scsw.actl == 0);
+				   (cdev->private->intparm == -EIO) ||
+				   (cdev->private->intparm == 0));
 			spin_lock_irqsave(&sch->lock, flags);
 			/* Check at least for channel end / device end */
-			if ((sch->schib.scsw.dstat !=
-			     (DEV_STAT_CHN_END|DEV_STAT_DEV_END)) ||
-			    (sch->schib.scsw.cstat != 0)) {
+			if (cdev->private->intparm) {
 				ret = -EIO;
 				continue;
 			}
@@ -350,13 +360,14 @@
 		if (ret)
 			continue;
 		/* Wait for end of request. */
+		cdev->private->intparm = 0x00524344; 
 		spin_unlock_irqrestore(&sch->lock, flags);
-		wait_event(cdev->private->wait_q, sch->schib.scsw.actl == 0);
+		wait_event(cdev->private->wait_q,
+			   (cdev->private->intparm == -EIO) ||
+			   (cdev->private->intparm == 0));
 		spin_lock_irqsave(&sch->lock, flags);
 		/* Check at least for channel end / device end */
-		if ((sch->schib.scsw.dstat != 
-		     (DEV_STAT_CHN_END|DEV_STAT_DEV_END)) ||
-		    (sch->schib.scsw.cstat != 0)) {
+		if (cdev->private->intparm) {
 			ret = -EIO;
 			continue;
 		}
drivers/s390/cio/qdio.c +6 -17
diff -urN linux-2.6/drivers/s390/cio/qdio.c linux-2.6-s390/drivers/s390/cio/qdio.c
@@ -55,7 +55,7 @@
 #include "ioasm.h"
 #include "chsc.h"
 
-#define VERSION_QDIO_C "$Revision: 1.55 $"
+#define VERSION_QDIO_C "$Revision: 1.58 $"
 
 /****************** MODULE PARAMETER VARIABLES ********************/
 MODULE_AUTHOR("Utz Bacher <[email protected]>");
@@ -120,15 +120,7 @@
 static inline unsigned long 
 qdio_get_millis(void)
 {
-	return (unsigned long)(qdio_get_micros()>>12);
-}
-
-static __inline__ int 
-atomic_return_add (int i, atomic_t *v)
-{
-	int old, new;
-	__CS_LOOP(old, new, v, i, "ar");
-	return old;
+	return (unsigned long)(qdio_get_micros()>>10);
 }
 
 static void 
@@ -181,7 +173,7 @@
 static inline int 
 qdio_reserve_q(struct qdio_q *q)
 {
-	return atomic_return_add(1,&q->use_count);
+	return atomic_add_return(1,&q->use_count) - 1;
 }
 
 static inline void 
@@ -1221,21 +1213,18 @@
 qdio_release_irq_memory(struct qdio_irq *irq_ptr)
 {
 	int i;
-	int available;
 
 	for (i=0;i<QDIO_MAX_QUEUES_PER_IRQ;i++) {
 		if (!irq_ptr->input_qs[i])
 			goto next;
-		available=0;
 
 		if (irq_ptr->input_qs[i]->slib)
 			kfree(irq_ptr->input_qs[i]->slib);
-			kfree(irq_ptr->input_qs[i]);
+		kfree(irq_ptr->input_qs[i]);
 
 next:
 		if (!irq_ptr->output_qs[i])
 			continue;
-		available=0;
 
 		if (irq_ptr->output_qs[i]->slib)
 			kfree(irq_ptr->output_qs[i]->slib);
@@ -2855,7 +2844,7 @@
 	int used_elements;
 
         /* This is the inbound handling of queues */
-	used_elements=atomic_return_add(count, &q->number_of_buffers_used);
+	used_elements=atomic_add_return(count, &q->number_of_buffers_used) - count;
 	
 	qdio_do_qdio_fill_input(q,qidx,count,buffers);
 	
@@ -2897,7 +2886,7 @@
 
 	qdio_do_qdio_fill_output(q,qidx,count,buffers);
 
-	used_elements=atomic_return_add(count, &q->number_of_buffers_used);
+	used_elements=atomic_add_return(count, &q->number_of_buffers_used) - count;
 
 	if (callflags&QDIO_FLAG_DONT_SIGA) {
 #ifdef QDIO_PERFORMANCE_STATS
#1 lore raw
Quoted 2 lines · Martin Schwidefsky
drivers/s390/cio/css.c +0 -0

[...]

Quoted 13 lines
drivers/s390/cio/css.c +1 -2
@@ -97,8 +85,7 @@
 	sch->dev.bus = &css_bus_type;
 
 	/* Set a name for the subchannel */
-	strlcpy (sch->dev.name, subchannel_types[sch->st], DEVICE_NAME_SIZE);
-	snprintf (sch->dev.bus_id, DEVICE_ID_SIZE, "0:%04x", sch->irq);
+	snprintf (sch->dev.bus_id, DEVICE_ID_SIZE, "0.0.%04x", sch->irq);
 
 	/* make it known to the system */
 	ret = device_register(&sch->dev);

diff -urN linux-2.6/drivers/s390/cio/device.c linux-2.6-s390/drivers/s390/cio/device.c

drivers/s390/cio/device.c +0 -0

[...]

drivers/s390/cio/device.c line 543

Quoted 10 lines
drivers/s390/cio/device.c +1 -2
@@ -537,8 +537,7 @@
 	init_timer(&cdev->private->timer);
 
 	/* Set an initial name for the device. */
-	snprintf (cdev->dev.name, DEVICE_NAME_SIZE,"ccw device");
-	snprintf (cdev->dev.bus_id, DEVICE_ID_SIZE, "0:%04x",
+	snprintf (cdev->dev.bus_id, DEVICE_ID_SIZE, "0.0.%04x",
 		  sch->schib.pmcw.dev);
 
 	/* Increase counter of devices currently in recognition. */

Shouldn't the above use BUS_ID_SIZE instead of DEVICE_ID_SIZE?

Signature · 1 line
OGAWA Hirofumi <[email protected]>
#2 lore raw
Quoted 9 lines · OGAWA Hirofumi
Quoted 9 lines
drivers/s390/cio/device.c +1 -2
@@ -537,8 +537,7 @@
 	init_timer(&cdev->private->timer);
 
 	/* Set an initial name for the device. */
-	snprintf (cdev->dev.name, DEVICE_NAME_SIZE,"ccw device");
-	snprintf (cdev->dev.bus_id, DEVICE_ID_SIZE, "0:%04x",
+	snprintf (cdev->dev.bus_id, DEVICE_ID_SIZE, "0.0.%04x",
 		  sch->schib.pmcw.dev);
 
Quoted 3 lines

drivers/s390/cio/device.c line 543

Quoted 1 line
drivers/s390/cio/device.c +0 -0
 	/* Increase counter of devices currently in recognition. */

Shouldn't the above use BUS_ID_SIZE instead of DEVICE_ID_SIZE?

Ooops. Sorry, I miss read it. I thought it's DEVICE_NAME_SIZE.

Signature · 1 line
OGAWA Hirofumi <[email protected]>
#3 lore raw
In reply to OGAWA Hirofumi
Quoted 32 lines · OGAWA Hirofumi
Quoted 2 lines · Martin Schwidefsky
drivers/s390/cio/css.c +0 -0

[...]

Quoted 13 lines
drivers/s390/cio/css.c +1 -2
@@ -97,8 +85,7 @@
 	sch->dev.bus = &css_bus_type;
 
 	/* Set a name for the subchannel */
-	strlcpy (sch->dev.name, subchannel_types[sch->st], DEVICE_NAME_SIZE);
-	snprintf (sch->dev.bus_id, DEVICE_ID_SIZE, "0:%04x", sch->irq);
+	snprintf (sch->dev.bus_id, DEVICE_ID_SIZE, "0.0.%04x", sch->irq);
 
 	/* make it known to the system */
 	ret = device_register(&sch->dev);

diff -urN linux-2.6/drivers/s390/cio/device.c linux-2.6-s390/drivers/s390/cio/device.c

drivers/s390/cio/device.c +0 -0

[...]

Quoted 9 lines
drivers/s390/cio/device.c +1 -2
@@ -537,8 +537,7 @@
 	init_timer(&cdev->private->timer);
 
 	/* Set an initial name for the device. */
-	snprintf (cdev->dev.name, DEVICE_NAME_SIZE,"ccw device");
-	snprintf (cdev->dev.bus_id, DEVICE_ID_SIZE, "0:%04x",
+	snprintf (cdev->dev.bus_id, DEVICE_ID_SIZE, "0.0.%04x",
 		  sch->schib.pmcw.dev);
 
Quoted 3 lines

drivers/s390/cio/device.c line 543

Quoted 1 line
drivers/s390/cio/device.c +0 -0
 	/* Increase counter of devices currently in recognition. */

Shouldn't the above use BUS_ID_SIZE instead of DEVICE_ID_SIZE?

Yes, DEVICE_ID_SIZE should be removed from the kernel, as it's not used for any structures, only some modules that use it improperly (including the USB core, I'll go fix that up right now...)

thanks,

greg k-h