Commit 0ce4eb3c authored by Jens Axboe's avatar Jens Axboe

Replace awful schedule_timeout polling code with

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