Skip to contentSkip to conversation

s390: SCLP device driver cleanup

PATCH In review Heiko Carstens 1 participant 1 message Dec 28, 2004 s390

lore
Share & tools
lore
#0 lore raw

PATCH 8/8 s390: SCLP device driver cleanup

[PATCH 8/8] s390: sclp driver.

From: Peter Oberparleiter <[email protected]>

sclp: core driver cleanup

Details:
- moved signal shutdown (quiesce) handling into a separate file
- cleanup of SCLP core driver:
. introduced driver states instead of bits
. introduced request retry count and retry limit
. sclp_add_request now returns an error code if a request couldn't be started . introduced separate request structure for init_mask requests to simplify
code
. request timer is now manually checked in sclp_sync_wait because timer
interrupts are disabled in this context
. removed busy timer - request timer now handles both cases
. split up sclp_start_request into __sclp_start_request and sclp_process
queue
. removed sclp_error_message (unused)
. introduced sclp_check_handler function to split up initial init mask
test from standard init mask request processing
. introduced sclp_deactivate and sclp_reactivate for simplified reboot
event handling (and potential use in suspend/resume scenario)
. added protection against multiple concurrent init mask calls
- minor changes in SCLP core driver:
. updated comments
. renamed functions to be consistent with "function name starts with __ =>
needs lock"
. renamed internal functions for consistency reasons
. introduced inlined helper functions to simplify code
. moved EXPORT_SYMBOL definitions next to function definition
- changes in sclp console driver
. removed callback recursion to prevent stack overflow
- changes to CPI module
. added check for sclp_add_request return code
. changed printks to specify a message level
- changes to generic sclp tty layer
. removed timed buffer retry after error (timers may not work in some
situations)
. introduced return code for sclp_emit_buffer
- changes to sclp tty driver
. removed callback recursion
- changes to sclp vt220 driver
. removed callback recursion
. removed timed buffer retry after error
- modified sclp_init_mask to prevent problems with some compiler versions

diffstat:

 drivers/s390/char/Makefile       |    2 
 drivers/s390/char/sclp.c         | 1266 ++++++++++++++++++++-------------------
 drivers/s390/char/sclp.h         |    6 
 drivers/s390/char/sclp_con.c     |   39 -
 drivers/s390/char/sclp_cpi.c     |   19 
 drivers/s390/char/sclp_quiesce.c |  114 +++
 drivers/s390/char/sclp_rw.c      |   62 -
 drivers/s390/char/sclp_rw.h      |    4 
 drivers/s390/char/sclp_tty.c     |   40 -
 drivers/s390/char/sclp_vt220.c   |   94 +-
 10 files changed, 896 insertions(+), 750 deletions(-)
drivers/s390/char/Makefile +1 -1
diff -urN linux-2.6/drivers/s390/char/Makefile linux-2.6-patched/drivers/s390/char/Makefile
@@ -11,7 +11,7 @@
 
 obj-$(CONFIG_TN3215) += con3215.o
 
-obj-$(CONFIG_SCLP) += sclp.o sclp_rw.o
+obj-$(CONFIG_SCLP) += sclp.o sclp_rw.o sclp_quiesce.o
 obj-$(CONFIG_SCLP_TTY) += sclp_tty.o
 obj-$(CONFIG_SCLP_CONSOLE) += sclp_con.o
 obj-$(CONFIG_SCLP_VT220_TTY) += sclp_vt220.o
drivers/s390/char/sclp.c +664 -602

1,493 lines not on this page · raw message

drivers/s390/char/sclp_con.c +20 -19
diff -urN linux-2.6/drivers/s390/char/sclp_con.c linux-2.6-patched/drivers/s390/char/sclp_con.c
@@ -49,25 +49,22 @@
 sclp_conbuf_callback(struct sclp_buffer *buffer, int rc)
 {
 	unsigned long flags;
-	struct sclp_buffer *next;
 	void *page;
 
-	/* Ignore return code - because console-writes aren't critical,
-	   we do without a sophisticated error recovery mechanism.  */
-	page = sclp_unmake_buffer(buffer);
-	spin_lock_irqsave(&sclp_con_lock, flags);
-	/* Remove buffer from outqueue */
-	list_del(&buffer->list);
-	sclp_con_buffer_count--;
-	list_add_tail((struct list_head *) page, &sclp_con_pages);
-	/* Check if there is a pending buffer on the out queue. */
-	next = NULL;
-	if (!list_empty(&sclp_con_outqueue))
-		next = list_entry(sclp_con_outqueue.next,
-				  struct sclp_buffer, list);
-	spin_unlock_irqrestore(&sclp_con_lock, flags);
-	if (next != NULL)
-		sclp_emit_buffer(next, sclp_conbuf_callback);
+	do {
+		page = sclp_unmake_buffer(buffer);
+		spin_lock_irqsave(&sclp_con_lock, flags);
+		/* Remove buffer from outqueue */
+		list_del(&buffer->list);
+		sclp_con_buffer_count--;
+		list_add_tail((struct list_head *) page, &sclp_con_pages);
+		/* Check if there is a pending buffer on the out queue. */
+		buffer = NULL;
+		if (!list_empty(&sclp_con_outqueue))
+			buffer = list_entry(sclp_con_outqueue.next,
+					    struct sclp_buffer, list);
+		spin_unlock_irqrestore(&sclp_con_lock, flags);
+	} while (buffer && sclp_emit_buffer(buffer, sclp_conbuf_callback));
 }
 
 static inline void
@@ -76,6 +73,7 @@
 	struct sclp_buffer* buffer;
 	unsigned long flags;
 	int count;
+	int rc;
 
 	spin_lock_irqsave(&sclp_con_lock, flags);
 	buffer = sclp_conbuf;
@@ -87,8 +85,11 @@
 	list_add_tail(&buffer->list, &sclp_con_outqueue);
 	count = sclp_con_buffer_count++;
 	spin_unlock_irqrestore(&sclp_con_lock, flags);
-	if (count == 0)
-		sclp_emit_buffer(buffer, sclp_conbuf_callback);
+	if (count)
+		return;
+	rc = sclp_emit_buffer(buffer, sclp_conbuf_callback);
+	if (rc)
+		sclp_conbuf_callback(buffer, rc);
 }
 
 /*
drivers/s390/char/sclp_cpi.c +14 -5
diff -urN linux-2.6/drivers/s390/char/sclp_cpi.c linux-2.6-patched/drivers/s390/char/sclp_cpi.c
@@ -196,18 +196,20 @@
 	rc = sclp_register(&sclp_cpi_event);
 	if (rc) {
 		/* could not register sclp event. Die. */
-		printk("cpi: could not register to hardware console.\n");
+		printk(KERN_WARNING "cpi: could not register to hardware "
+		       "console.\n");
 		return -EINVAL;
 	}
 	if (!(sclp_cpi_event.sclp_send_mask & EvTyp_CtlProgIdent_Mask)) {
-		printk("cpi: no control program identification support\n");
+		printk(KERN_WARNING "cpi: no control program identification "
+		       "support\n");
 		sclp_unregister(&sclp_cpi_event);
 		return -ENOTSUPP;
 	}
 
 	req = cpi_prepare_req();
 	if (IS_ERR(req)) {
-		printk("cpi: couldn't allocate request\n");
+		printk(KERN_WARNING "cpi: couldn't allocate request\n");
 		sclp_unregister(&sclp_cpi_event);
 		return PTR_ERR(req);
 	}
@@ -216,13 +218,20 @@
 	sema_init(&sem, 0);
 	req->callback_data = &sem;
 	/* Add request to sclp queue */
-	sclp_add_request(req);
+	rc = sclp_add_request(req);
+	if (rc) {
+		printk(KERN_WARNING "cpi: could not start request\n");
+		cpi_free_req(req);
+		sclp_unregister(&sclp_cpi_event);
+		return rc;
+	}
 	/* make "insmod" sleep until callback arrives */
 	down(&sem);
 
 	rc = ((struct cpi_sccb *) req->sccb)->header.response_code;
 	if (rc != 0x0020) {
-		printk("cpi: failed with response code 0x%x\n", rc);
+		printk(KERN_WARNING "cpi: failed with response code 0x%x\n",
+		       rc);
 		rc = -ECOMM;
 	} else
 		rc = 0;
drivers/s390/char/sclp.h +4 -2
diff -urN linux-2.6/drivers/s390/char/sclp.h linux-2.6-patched/drivers/s390/char/sclp.h
@@ -95,6 +95,7 @@
 	sclp_cmdw_t command;		/* sclp command to execute */
 	void	*sccb;			/* pointer to the sccb to execute */
 	char	status;			/* status of this request */
+	int     start_count;		/* number of SVCs done for this req */
 	/* Callback that is called after reaching final status. */
 	void (*callback)(struct sclp_req *, void *data);
 	void *callback_data;
@@ -123,12 +124,13 @@
 };
 
 /* externals from sclp.c */
-void sclp_add_request(struct sclp_req *req);
+int sclp_add_request(struct sclp_req *req);
 void sclp_sync_wait(void);
 int sclp_register(struct sclp_register *reg);
 void sclp_unregister(struct sclp_register *reg);
-char *sclp_error_message(u16 response_code);
 int sclp_remove_processed(struct sccb_header *sccb);
+int sclp_deactivate(void);
+int sclp_reactivate(void);
 
 /* useful inlines */
 
drivers/s390/char/sclp_quiesce.c +114 -0

114 lines not on this page · raw message

drivers/s390/char/sclp_rw.c +23 -39

116 lines not on this page · raw message

drivers/s390/char/sclp_rw.h +1 -3
diff -urN linux-2.6/drivers/s390/char/sclp_rw.h linux-2.6-patched/drivers/s390/char/sclp_rw.h
@@ -12,7 +12,6 @@
 #define __SCLP_RW_H__
 
 #include <linux/list.h>
-#include <linux/timer.h>
 
 struct mto {
 	u16 length;
@@ -74,7 +73,6 @@
 	char *current_line;
 	int current_length;
 	int retry_count;
-	struct timer_list retry_timer;
 	/* output format settings */
 	unsigned short columns;
 	unsigned short htab;
@@ -90,7 +88,7 @@
 void *sclp_unmake_buffer(struct sclp_buffer *);
 int sclp_buffer_space(struct sclp_buffer *);
 int sclp_write(struct sclp_buffer *buffer, const unsigned char *, int);
-void sclp_emit_buffer(struct sclp_buffer *,void (*)(struct sclp_buffer *,int));
+int sclp_emit_buffer(struct sclp_buffer *,void (*)(struct sclp_buffer *,int));
 void sclp_set_columns(struct sclp_buffer *, unsigned short);
 void sclp_set_htab(struct sclp_buffer *, unsigned short);
 int sclp_chars_in_buffer(struct sclp_buffer *);
drivers/s390/char/sclp_tty.c +20 -20
diff -urN linux-2.6/drivers/s390/char/sclp_tty.c linux-2.6-patched/drivers/s390/char/sclp_tty.c
@@ -255,25 +255,22 @@
 sclp_ttybuf_callback(struct sclp_buffer *buffer, int rc)
 {
 	unsigned long flags;
-	struct sclp_buffer *next;
 	void *page;
 
-	/* Ignore return code - because tty-writes aren't critical,
-	   we do without a sophisticated error recovery mechanism.  */
-	page = sclp_unmake_buffer(buffer);
-	spin_lock_irqsave(&sclp_tty_lock, flags);
-	/* Remove buffer from outqueue */
-	list_del(&buffer->list);
-	sclp_tty_buffer_count--;
-	list_add_tail((struct list_head *) page, &sclp_tty_pages);
-	/* Check if there is a pending buffer on the out queue. */
-	next = NULL;
-	if (!list_empty(&sclp_tty_outqueue))
-		next = list_entry(sclp_tty_outqueue.next,
-				  struct sclp_buffer, list);
-	spin_unlock_irqrestore(&sclp_tty_lock, flags);
-	if (next != NULL)
-		sclp_emit_buffer(next, sclp_ttybuf_callback);
+	do {
+		page = sclp_unmake_buffer(buffer);
+		spin_lock_irqsave(&sclp_tty_lock, flags);
+		/* Remove buffer from outqueue */
+		list_del(&buffer->list);
+		sclp_tty_buffer_count--;
+		list_add_tail((struct list_head *) page, &sclp_tty_pages);
+		/* Check if there is a pending buffer on the out queue. */
+		buffer = NULL;
+		if (!list_empty(&sclp_tty_outqueue))
+			buffer = list_entry(sclp_tty_outqueue.next,
+					    struct sclp_buffer, list);
+		spin_unlock_irqrestore(&sclp_tty_lock, flags);
+	} while (buffer && sclp_emit_buffer(buffer, sclp_ttybuf_callback));
 	wake_up(&sclp_tty_waitq);
 	/* check if the tty needs a wake up call */
 	if (sclp_tty != NULL) {
@@ -286,14 +283,17 @@
 {
 	unsigned long flags;
 	int count;
+	int rc;
 
 	spin_lock_irqsave(&sclp_tty_lock, flags);
 	list_add_tail(&buffer->list, &sclp_tty_outqueue);
 	count = sclp_tty_buffer_count++;
 	spin_unlock_irqrestore(&sclp_tty_lock, flags);
-
-	if (count == 0)
-		sclp_emit_buffer(buffer, sclp_ttybuf_callback);
+	if (count)
+		return;
+	rc = sclp_emit_buffer(buffer, sclp_ttybuf_callback);
+	if (rc)
+		sclp_ttybuf_callback(buffer, rc);
 }
 
 /*
drivers/s390/char/sclp_vt220.c +35 -59

169 lines not on this page · raw message