Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6
[pandora-kernel.git] / drivers / net / myri10ge / myri10ge.c
index ee1de97..9bdd43a 100644 (file)
@@ -177,6 +177,7 @@ struct myri10ge_priv {
        struct work_struct watchdog_work;
        struct timer_list watchdog_timer;
        int watchdog_tx_done;
+       int watchdog_tx_req;
        int watchdog_resets;
        int tx_linearized;
        int pause;
@@ -448,6 +449,7 @@ static int myri10ge_load_hotplug_firmware(struct myri10ge_priv *mgp, u32 * size)
        struct mcp_gen_header *hdr;
        size_t hdr_offset;
        int status;
+       unsigned i;
 
        if ((status = request_firmware(&fw, mgp->fw_name, dev)) < 0) {
                dev_err(dev, "Unable to load %s firmware image via hotplug\n",
@@ -479,18 +481,12 @@ static int myri10ge_load_hotplug_firmware(struct myri10ge_priv *mgp, u32 * size)
                goto abort_with_fw;
 
        crc = crc32(~0, fw->data, fw->size);
-       if (mgp->tx.boundary == 2048) {
-               /* Avoid PCI burst on chipset with unaligned completions. */
-               int i;
-               __iomem u32 *ptr = (__iomem u32 *) (mgp->sram +
-                                                   MYRI10GE_FW_OFFSET);
-               for (i = 0; i < fw->size / 4; i++) {
-                       __raw_writel(((u32 *) fw->data)[i], ptr + i);
-                       wmb();
-               }
-       } else {
-               myri10ge_pio_copy(mgp->sram + MYRI10GE_FW_OFFSET, fw->data,
-                                 fw->size);
+       for (i = 0; i < fw->size; i += 256) {
+               myri10ge_pio_copy(mgp->sram + MYRI10GE_FW_OFFSET + i,
+                                 fw->data + i,
+                                 min(256U, (unsigned)(fw->size - i)));
+               mb();
+               readb(mgp->sram);
        }
        /* corruption checking is good for parity recovery and buggy chipset */
        memcpy_fromio(fw->data, mgp->sram + MYRI10GE_FW_OFFSET, fw->size);
@@ -620,7 +616,7 @@ static int myri10ge_load_firmware(struct myri10ge_priv *mgp)
                return -ENXIO;
        }
        dev_info(&mgp->pdev->dev, "handoff confirmed\n");
-       myri10ge_dummy_rdma(mgp, mgp->tx.boundary != 4096);
+       myri10ge_dummy_rdma(mgp, 1);
 
        return 0;
 }
@@ -2412,18 +2408,24 @@ static int myri10ge_resume(struct pci_dev *pdev)
                return -EIO;
        }
        myri10ge_restore_state(mgp);
-       pci_enable_device(pdev);
+
+       status = pci_enable_device(pdev);
+       if (status < 0) {
+               dev_err(&pdev->dev, "failed to enable device\n");
+               return -EIO;
+       }
+
        pci_set_master(pdev);
 
        status = request_irq(pdev->irq, myri10ge_intr, IRQF_SHARED,
                             netdev->name, mgp);
        if (status != 0) {
                dev_err(&pdev->dev, "failed to allocate IRQ\n");
-               goto abort_with_msi;
+               goto abort_with_enabled;
        }
 
        myri10ge_reset(mgp);
-       myri10ge_dummy_rdma(mgp, mgp->tx.boundary != 4096);
+       myri10ge_dummy_rdma(mgp, 1);
 
        /* Save configuration space to be restored if the
         * nic resets due to a parity error */
@@ -2438,7 +2440,8 @@ static int myri10ge_resume(struct pci_dev *pdev)
 
        return 0;
 
-abort_with_msi:
+abort_with_enabled:
+       pci_disable_device(pdev);
        return -EIO;
 
 }
@@ -2540,7 +2543,8 @@ static void myri10ge_watchdog_timer(unsigned long arg)
 
        mgp = (struct myri10ge_priv *)arg;
        if (mgp->tx.req != mgp->tx.done &&
-           mgp->tx.done == mgp->watchdog_tx_done)
+           mgp->tx.done == mgp->watchdog_tx_done &&
+           mgp->watchdog_tx_req != mgp->watchdog_tx_done)
                /* nic seems like it might be stuck.. */
                schedule_work(&mgp->watchdog_work);
        else
@@ -2549,6 +2553,7 @@ static void myri10ge_watchdog_timer(unsigned long arg)
                          jiffies + myri10ge_watchdog_timeout * HZ);
 
        mgp->watchdog_tx_done = mgp->tx.done;
+       mgp->watchdog_tx_req = mgp->tx.req;
 }
 
 static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)