Skip to content

Commit 76f73ca

Browse files
Jarod WilsonStefan Richter
authored andcommitted
firewire: fw-ohci: don't append to AT context when it's not active
I finally tracked down the issues with this JMicron PCI-e card in my possession to a failure to comply with section 7.2.3.2 of the OHCI 1.1 specification (thanks to Kristian for the pointer to illustrate that it is indeed a flaw in this card, not the driver). The controller should simply flush the packets we've appended to its AT queue if a bus reset occurs before they've been transmitted and we'll try again, but something goes wrong and the controller winds up hung. However, we can avoid the problem by simply checking if the IntEvent.busReset register had been set before we try appending to the AT context. When busReset is set, the AT context is completely halted until busReset is cleared, so there's no point in appending AT packets until the register is cleared. So at_context_queue_packet() now checks for busReset being set, and bails with an RCODE_GENERATION packet ack, which results in us trying to append the packet again after recognizing the fact there has been a bus reset, and clearing busReset. Signed-off-by: Jarod Wilson <jwilson@redhat.com> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
1 parent 75f7832 commit 76f73ca

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

drivers/firewire/fw-ohci.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -950,8 +950,19 @@ at_context_queue_packet(struct context *ctx, struct fw_packet *packet)
950950
DESCRIPTOR_IRQ_ALWAYS |
951951
DESCRIPTOR_BRANCH_ALWAYS);
952952

953-
/* FIXME: Document how the locking works. */
954-
if (ohci->generation != packet->generation) {
953+
/*
954+
* If the controller and packet generations don't match, we need to
955+
* bail out and try again. If IntEvent.busReset is set, the AT context
956+
* is halted, so appending to the context and trying to run it is
957+
* futile. Most controllers do the right thing and just flush the AT
958+
* queue (per section 7.2.3.2 of the OHCI 1.1 specification), but
959+
* some controllers (like a JMicron JMB381 PCI-e) misbehave and wind
960+
* up stalling out. So we just bail out in software and try again
961+
* later, and everyone is happy.
962+
* FIXME: Document how the locking works.
963+
*/
964+
if (ohci->generation != packet->generation ||
965+
reg_read(ohci, OHCI1394_IntEventSet) & OHCI1394_busReset) {
955966
if (packet->payload_length > 0)
956967
dma_unmap_single(ohci->card.device, payload_bus,
957968
packet->payload_length, DMA_TO_DEVICE);

0 commit comments

Comments
 (0)