]> err.no Git - linux-2.6/blobdiff - drivers/block/cciss.c
Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[linux-2.6] / drivers / block / cciss.c
index 74818cc6509be0bd8d9b4b746b999352bd6897e7..e29b8926f80ed08e1c618e236c8186720f0f1ea9 100644 (file)
@@ -2137,7 +2137,7 @@ static void start_io( ctlr_info_t *h)
                        break;
                }
 
-               /* Get the frist entry from the Request Q */ 
+               /* Get the first entry from the Request Q */ 
                removeQ(&(h->reqQ), c);
                h->Qdepth--;
        
@@ -2178,16 +2178,49 @@ static inline void resend_cciss_cmd( ctlr_info_t *h, CommandList_struct *c)
 
        start_io(h);
 }
+
+static void cciss_softirq_done(struct request *rq)
+{
+       CommandList_struct *cmd = rq->completion_data;
+       ctlr_info_t *h = hba[cmd->ctlr];
+       unsigned long flags;
+       u64bit temp64;
+       int i, ddir;
+
+       if (cmd->Request.Type.Direction == XFER_READ)
+               ddir = PCI_DMA_FROMDEVICE;
+       else
+               ddir = PCI_DMA_TODEVICE;
+
+       /* command did not need to be retried */
+       /* unmap the DMA mapping for all the scatter gather elements */
+       for(i=0; i<cmd->Header.SGList; i++) {
+               temp64.val32.lower = cmd->SG[i].Addr.lower;
+               temp64.val32.upper = cmd->SG[i].Addr.upper;
+               pci_unmap_page(h->pdev, temp64.val, cmd->SG[i].Len, ddir);
+       }
+
+       complete_buffers(rq->bio, rq->errors);
+
+#ifdef CCISS_DEBUG
+       printk("Done with %p\n", rq);
+#endif /* CCISS_DEBUG */ 
+
+       spin_lock_irqsave(&h->lock, flags);
+       end_that_request_last(rq, rq->errors);
+       cmd_free(h, cmd,1);
+       spin_unlock_irqrestore(&h->lock, flags);
+}
+
 /* checks the status of the job and calls complete buffers to mark all 
- * buffers for the completed job. 
+ * buffers for the completed job. Note that this function does not need
+ * to hold the hba/queue lock.
  */ 
 static inline void complete_command( ctlr_info_t *h, CommandList_struct *cmd,
                int timeout)
 {
        int status = 1;
-       int i;
        int retry_cmd = 0;
-       u64bit temp64;
                
        if (timeout)
                status = 0; 
@@ -2295,24 +2328,10 @@ static inline void complete_command( ctlr_info_t *h, CommandList_struct *cmd,
                resend_cciss_cmd(h,cmd);
                return;
        }       
-       /* command did not need to be retried */
-       /* unmap the DMA mapping for all the scatter gather elements */
-       for(i=0; i<cmd->Header.SGList; i++) {
-               temp64.val32.lower = cmd->SG[i].Addr.lower;
-               temp64.val32.upper = cmd->SG[i].Addr.upper;
-               pci_unmap_page(hba[cmd->ctlr]->pdev,
-                       temp64.val, cmd->SG[i].Len,
-                       (cmd->Request.Type.Direction == XFER_READ) ?
-                               PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE);
-       }
-       complete_buffers(cmd->rq->bio, status);
 
-#ifdef CCISS_DEBUG
-       printk("Done with %p\n", cmd->rq);
-#endif /* CCISS_DEBUG */ 
-
-       end_that_request_last(cmd->rq, status ? 1 : -EIO);
-       cmd_free(h,cmd,1);
+       cmd->rq->completion_data = cmd;
+       cmd->rq->errors = status;
+       blk_complete_request(cmd->rq);
 }
 
 /* 
@@ -3118,7 +3137,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
         * 8 controller support.
         */
        if (i < MAX_CTLR_ORIG)
-               hba[i]->major = MAJOR_NR + i;
+               hba[i]->major = COMPAQ_CISS_MAJOR + i;
        rc = register_blkdev(hba[i]->major, hba[i]->devname);
        if(rc == -EBUSY || rc == -EINVAL) {
                printk(KERN_ERR
@@ -3199,15 +3218,17 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
                drv->queue = q;
 
                q->backing_dev_info.ra_pages = READ_AHEAD;
-       blk_queue_bounce_limit(q, hba[i]->pdev->dma_mask);
+               blk_queue_bounce_limit(q, hba[i]->pdev->dma_mask);
 
-       /* This is a hardware imposed limit. */
-       blk_queue_max_hw_segments(q, MAXSGENTRIES);
+               /* This is a hardware imposed limit. */
+               blk_queue_max_hw_segments(q, MAXSGENTRIES);
 
-       /* This is a limit in the driver and could be eliminated. */
-       blk_queue_max_phys_segments(q, MAXSGENTRIES);
+               /* This is a limit in the driver and could be eliminated. */
+               blk_queue_max_phys_segments(q, MAXSGENTRIES);
 
-       blk_queue_max_sectors(q, 512);
+               blk_queue_max_sectors(q, 512);
+
+               blk_queue_softirq_done(q, cciss_softirq_done);
 
                q->queuedata = hba[i];
                sprintf(disk->disk_name, "cciss/c%dd%d", i, j);
@@ -3230,8 +3251,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
 
 clean4:
 #ifdef CONFIG_CISS_SCSI_TAPE
-       if(hba[i]->scsi_rejects.complete)
-               kfree(hba[i]->scsi_rejects.complete);
+       kfree(hba[i]->scsi_rejects.complete);
 #endif
        kfree(hba[i]->cmd_pool_bits);
        if(hba[i]->cmd_pool)
@@ -3248,8 +3268,8 @@ clean2:
        unregister_blkdev(hba[i]->major, hba[i]->devname);
 clean1:
        release_io_mem(hba[i]);
-       free_hba(i);
        hba[i]->busy_initializing = 0;
+       free_hba(i);
        return(-1);
 }
 
@@ -3340,7 +3360,7 @@ static int __init cciss_init(void)
        printk(KERN_INFO DRIVER_NAME "\n");
 
        /* Register for our PCI devices */
-       return pci_module_init(&cciss_pci_driver);
+       return pci_register_driver(&cciss_pci_driver);
 }
 
 static void __exit cciss_cleanup(void)