NVMe: Rename cancel_cmdid_data to cancel_cmdid
[linux-2.6.git] / drivers / block / nvme.c
index 90a96ec..9ca9db9 100644 (file)
@@ -213,10 +213,13 @@ static unsigned long free_cmdid(struct nvme_queue *nvmeq, int cmdid)
        return data;
 }
 
-static void cancel_cmdid_data(struct nvme_queue *nvmeq, int cmdid)
+static unsigned long cancel_cmdid(struct nvme_queue *nvmeq, int cmdid)
 {
+       unsigned long data;
        struct nvme_cmd_info *info = nvme_cmd_info(nvmeq);
+       data = info[cmdid].ctx;
        info[cmdid].ctx = CMD_CTX_CANCELLED;
+       return data;
 }
 
 static struct nvme_queue *get_nvmeq(struct nvme_ns *ns)
@@ -310,9 +313,9 @@ static void bio_completion(struct nvme_queue *nvmeq, void *ctx,
        dma_unmap_sg(nvmeq->q_dmadev, nbio->sg, nbio->nents,
                        bio_data_dir(bio) ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
        free_nbio(nvmeq, nbio);
-       if (status)
+       if (status) {
                bio_endio(bio, -EIO);
-       if (bio->bi_vcnt > bio->bi_idx) {
+       } else if (bio->bi_vcnt > bio->bi_idx) {
                bio_list_add(&nvmeq->sq_cong, bio);
                wake_up_process(nvme_thread);
        } else {
@@ -667,7 +670,7 @@ static irqreturn_t nvme_irq_check(int irq, void *data)
 static void nvme_abort_command(struct nvme_queue *nvmeq, int cmdid)
 {
        spin_lock_irq(&nvmeq->q_lock);
-       cancel_cmdid_data(nvmeq, cmdid);
+       cancel_cmdid(nvmeq, cmdid);
        spin_unlock_irq(&nvmeq->q_lock);
 }
 
@@ -781,8 +784,10 @@ static int adapter_delete_sq(struct nvme_dev *dev, u16 sqid)
 static void nvme_free_queue(struct nvme_dev *dev, int qid)
 {
        struct nvme_queue *nvmeq = dev->queues[qid];
+       int vector = dev->entry[nvmeq->cq_vector].vector;
 
-       free_irq(dev->entry[nvmeq->cq_vector].vector, nvmeq);
+       irq_set_affinity_hint(vector, NULL);
+       free_irq(vector, nvmeq);
 
        /* Don't tell the adapter to delete the admin queue */
        if (qid) {
@@ -891,6 +896,8 @@ static int __devinit nvme_configure_admin_queue(struct nvme_dev *dev)
 {
        int result;
        u32 aqa;
+       u64 cap;
+       unsigned long timeout;
        struct nvme_queue *nvmeq;
 
        dev->dbs = ((void __iomem *)dev->bar) + 4096;
@@ -905,6 +912,7 @@ static int __devinit nvme_configure_admin_queue(struct nvme_dev *dev)
        dev->ctrl_config = NVME_CC_ENABLE | NVME_CC_CSS_NVM;
        dev->ctrl_config |= (PAGE_SHIFT - 12) << NVME_CC_MPS_SHIFT;
        dev->ctrl_config |= NVME_CC_ARB_RR | NVME_CC_SHN_NONE;
+       dev->ctrl_config |= NVME_CC_IOSQES | NVME_CC_IOCQES;
 
        writel(0, &dev->bar->cc);
        writel(aqa, &dev->bar->aqa);
@@ -912,10 +920,18 @@ static int __devinit nvme_configure_admin_queue(struct nvme_dev *dev)
        writeq(nvmeq->cq_dma_addr, &dev->bar->acq);
        writel(dev->ctrl_config, &dev->bar->cc);
 
+       cap = readq(&dev->bar->cap);
+       timeout = ((NVME_CAP_TIMEOUT(cap) + 1) * HZ / 2) + jiffies;
+
        while (!(readl(&dev->bar->csts) & NVME_CSTS_RDY)) {
                msleep(100);
                if (fatal_signal_pending(current))
                        return -EINTR;
+               if (time_after(jiffies, timeout)) {
+                       dev_err(&dev->pci_dev->dev,
+                               "Device not ready; aborting initialisation\n");
+                       return -ENODEV;
+               }
        }
 
        result = queue_request_irq(dev, nvmeq, "nvme admin");
@@ -1630,6 +1646,6 @@ static void __exit nvme_exit(void)
 
 MODULE_AUTHOR("Matthew Wilcox <willy@linux.intel.com>");
 MODULE_LICENSE("GPL");
-MODULE_VERSION("0.4");
+MODULE_VERSION("0.5");
 module_init(nvme_init);
 module_exit(nvme_exit);