firewire: fw-ohci: don't append to AT context when it's not active
[cascardo/linux.git] / drivers / firewire / fw-ohci.c
index e88260b..4789300 100644 (file)
@@ -257,7 +257,7 @@ static void log_irqs(u32 evt)
        if (likely(!(param_debug & OHCI_PARAM_DEBUG_IRQS)))
                return;
 
-       printk(KERN_DEBUG KBUILD_MODNAME ": IRQ %08x%s%s%s%s%s%s%s%s%s%s%s\n",
+       printk(KERN_DEBUG KBUILD_MODNAME ": IRQ %08x%s%s%s%s%s%s%s%s%s%s%s%s\n",
               evt,
               evt & OHCI1394_selfIDComplete    ? " selfID"             : "",
               evt & OHCI1394_RQPkt             ? " AR_req"             : "",
@@ -269,11 +269,13 @@ static void log_irqs(u32 evt)
               evt & OHCI1394_postedWriteErr    ? " postedWriteErr"     : "",
               evt & OHCI1394_cycleTooLong      ? " cycleTooLong"       : "",
               evt & OHCI1394_cycle64Seconds    ? " cycle64Seconds"     : "",
+              evt & OHCI1394_regAccessFail     ? " regAccessFail"      : "",
               evt & ~(OHCI1394_selfIDComplete | OHCI1394_RQPkt |
                       OHCI1394_RSPkt | OHCI1394_reqTxComplete |
                       OHCI1394_respTxComplete | OHCI1394_isochRx |
                       OHCI1394_isochTx | OHCI1394_postedWriteErr |
-                      OHCI1394_cycleTooLong | OHCI1394_cycle64Seconds)
+                      OHCI1394_cycleTooLong | OHCI1394_cycle64Seconds |
+                      OHCI1394_regAccessFail)
                                                ? " ?"                  : "");
 }
 
@@ -948,8 +950,19 @@ at_context_queue_packet(struct context *ctx, struct fw_packet *packet)
                                     DESCRIPTOR_IRQ_ALWAYS |
                                     DESCRIPTOR_BRANCH_ALWAYS);
 
-       /* FIXME: Document how the locking works. */
-       if (ohci->generation != packet->generation) {
+       /*
+        * If the controller and packet generations don't match, we need to
+        * bail out and try again.  If IntEvent.busReset is set, the AT context
+        * is halted, so appending to the context and trying to run it is
+        * futile.  Most controllers do the right thing and just flush the AT
+        * queue (per section 7.2.3.2 of the OHCI 1.1 specification), but
+        * some controllers (like a JMicron JMB381 PCI-e) misbehave and wind
+        * up stalling out.  So we just bail out in software and try again
+        * later, and everyone is happy.
+        * FIXME: Document how the locking works.
+        */
+       if (ohci->generation != packet->generation ||
+           reg_read(ohci, OHCI1394_IntEventSet) & OHCI1394_busReset) {
                if (packet->payload_length > 0)
                        dma_unmap_single(ohci->card.device, payload_bus,
                                         packet->payload_length, DMA_TO_DEVICE);
@@ -1351,6 +1364,10 @@ static irqreturn_t irq_handler(int irq, void *data)
                iso_event &= ~(1 << i);
        }
 
+       if (unlikely(event & OHCI1394_regAccessFail))
+               fw_error("Register access failure - "
+                        "please notify linux1394-devel@lists.sf.net\n");
+
        if (unlikely(event & OHCI1394_postedWriteErr))
                fw_error("PCI posted write error\n");
 
@@ -1448,7 +1465,8 @@ static int ohci_enable(struct fw_card *card, u32 *config_rom, size_t length)
                  OHCI1394_reqTxComplete | OHCI1394_respTxComplete |
                  OHCI1394_isochRx | OHCI1394_isochTx |
                  OHCI1394_postedWriteErr | OHCI1394_cycleTooLong |
-                 OHCI1394_cycle64Seconds | OHCI1394_masterIntEnable);
+                 OHCI1394_cycle64Seconds | OHCI1394_regAccessFail |
+                 OHCI1394_masterIntEnable);
 
        /* Activate link_on bit and contender bit in our self ID packets.*/
        if (ohci_update_phy_reg(card, 4, 0,