]> git.neil.brown.name Git - history.git/commitdiff
Replace awful schedule_timeout polling code with
authorJens Axboe <axboe@burns.home.kernel.dk>
Mon, 11 Feb 2002 10:39:04 +0000 (11:39 +0100)
committerJens Axboe <axboe@burns.home.kernel.dk>
Mon, 11 Feb 2002 10:39:04 +0000 (11:39 +0100)
completions.  Applies to 2.5.4-pre3
-- steve.cameron@compaq.com

drivers/block/cciss.c
drivers/block/cciss_cmd.h
drivers/block/cciss_scsi.c

index f9ac934d8c6a19722056f3a8a67ffa0e3749a7f4..f463a0a7ebe605b9010c0db798b412c5161cabba 100644 (file)
@@ -647,6 +647,7 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
                char    *buff = NULL;
                u64bit  temp64;
                unsigned long flags;
+               DECLARE_COMPLETION(wait);
 
                if (!arg) return -EINVAL;
        
@@ -712,6 +713,8 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
                        c->SG[0].Len = iocommand.buf_size;
                        c->SG[0].Ext = 0;  // we are not chaining
                }
+               c->waiting = &wait;
+
                /* Put the request on the tail of the request queue */
                spin_lock_irqsave(CCISS_LOCK(ctlr), flags);
                addQ(&h->reqQ, c);
@@ -719,9 +722,7 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
                start_io(h);
                spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
 
-               /* Wait for completion */
-               while(c->cmd_type != CMD_IOCTL_DONE)
-                       schedule_timeout(1);
+               wait_for_completion(&wait);
 
                /* unlock the buffers from DMA */
                temp64.val32.lower = c->SG[0].Addr.lower;
@@ -933,6 +934,7 @@ static int sendcmd_withirq(__u8     cmd,
        u64bit  buff_dma_handle;
        unsigned long flags;
        int return_status = IO_OK;
+       DECLARE_COMPLETION(wait);
        
        if ((c = cmd_alloc(h , 0)) == NULL)
        {
@@ -1026,6 +1028,7 @@ static int sendcmd_withirq(__u8   cmd,
                c->SG[0].Len = size;
                c->SG[0].Ext = 0;  // we are not chaining
        }
+       c->waiting = &wait;
        
        /* Put the request on the tail of the queue and send it */
        spin_lock_irqsave(CCISS_LOCK(ctlr), flags);
@@ -1034,9 +1037,8 @@ static int sendcmd_withirq(__u8   cmd,
        start_io(h);
        spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
        
-       /* wait for completion */ 
-       while(c->cmd_type != CMD_IOCTL_DONE)
-               schedule_timeout(1);
+       wait_for_completion(&wait);
+
        /* unlock the buffers from DMA */
         pci_unmap_single( h->pdev, (dma_addr_t) buff_dma_handle.val,
                        size, PCI_DMA_BIDIRECTIONAL);
@@ -1959,7 +1961,7 @@ static void do_cciss_intr(int irq, void *dev_id, struct pt_regs *regs)
                                        complete_command(c, 0);
                                        cmd_free(h, c, 1);
                                } else if (c->cmd_type == CMD_IOCTL_PEND) {
-                                       c->cmd_type = CMD_IOCTL_DONE;
+                                       complete(c->waiting);
                                }
 #                              ifdef CONFIG_CISS_SCSI_TAPE
                                else if (c->cmd_type == CMD_SCSI)
index cf9c9fd361b2986f82dcc179e8947e812b056e9f..f2449b22ec8623501720a33ef874ed7f5ba88d4e 100644 (file)
@@ -222,7 +222,6 @@ typedef struct _ErrorInfo_struct {
 /* Command types */
 #define CMD_RWREQ       0x00
 #define CMD_IOCTL_PEND  0x01
-#define CMD_IOCTL_DONE  0x02
 #define CMD_SCSI       0x03
 #define CMD_MSG_DONE   0x04
 #define CMD_MSG_TIMEOUT 0x05
@@ -240,6 +239,7 @@ typedef struct _CommandList_struct {
   struct _CommandList_struct *prev;
   struct _CommandList_struct *next;
   struct request *        rq;
+  struct completion *waiting;
 #ifdef CONFIG_CISS_SCSI_TAPE
   void * scsi_cmd;
 #endif
index 13cf784798cae402e5bb6341d0ea143b2737e634..5adb5494a6d5f7a8454a5d407c2539350f5ae10c 100644 (file)
@@ -897,6 +897,7 @@ cciss_scsi_do_simple_cmd(ctlr_info_t *c,
                        int direction)
 {
        unsigned long flags;
+       DECLARE_COMPLETION(wait);
 
        cp->cmd_type = CMD_IOCTL_PEND;          // treat this like an ioctl 
        cp->scsi_cmd = NULL;
@@ -922,6 +923,8 @@ cciss_scsi_do_simple_cmd(ctlr_info_t *c,
                        (unsigned char *) buf, bufsize,
                        scsi_to_pci_dma_dir(SCSI_DATA_READ)); 
 
+       cp->waiting = &wait;
+
        /* Put the request on the tail of the request queue */
        spin_lock_irqsave(CCISS_LOCK(c->ctlr), flags);
        addQ(&c->reqQ, cp);
@@ -929,9 +932,7 @@ cciss_scsi_do_simple_cmd(ctlr_info_t *c,
        start_io(c);
        spin_unlock_irqrestore(CCISS_LOCK(c->ctlr), flags);
 
-       /* Wait for the request to complete */
-       while(cp->cmd_type != CMD_IOCTL_DONE)
-               schedule_timeout(1);
+       wait_for_completion(&wait);
 
        /* undo the dma mapping */
        cciss_unmap_one(c->pdev, cp, bufsize,