i3c: mipi-i3c-hci: Don't rewind ring on timeout
On every transfer timeout, hci_dma_dequeue_xfer() moves CR_ENQ_PTR back
to CR_SW_DEQ_PTR, a downstream addition meant for the target mode halt
reset. CR_SW_DEQ_PTR only advances when software handles a response, so
it trails the hardware dequeue pointer whenever a finished transfer has
not been processed yet, for instance after a missed completion
interrupt. Rewinding then leaves the enqueue pointer behind the dequeue
pointer, and on restart the controller re-executes up to 255 stale
descriptors. Their responses land on freed transfers: a burst of
"response tid=N when expecting M" after "Ring 0: Transfer Aborted",
then a NULL pointer dereference in dma_unmap_phys() from the interrupt
handler. The rewind also drops entries other devices queued behind the
timed-out one.
Like upstream, leave CR_ENQ_PTR alone after a timeout, since the
timed-out entries are already No-Ops. For the target mode halt reset,
which passes no transfer list and discards everything still queued,
move CR_ENQ_PTR back to the hardware dequeue pointer instead, and unmap
and release the discarded entries.
The rewind's RING_OPERATION1 write also served as the doorbell an
aborted ring needs, written while it runs, before it resumes. Write
RING_OPERATION1 back unchanged after restarting the ring, so entries
queued behind the timed-out ones don't wait for the next transfer.
Tested: AST2700 A2 BMC, with a test-only patch that makes the
interrupt handler ignore TRANSFER_COMPLETION on the bus carrying the
host CPU's MCTP endpoint, so transfers time out with their response
unread. Without this series, including with only the four upstream
dequeue fixes it is based on, each timeout replayed stale ring
entries (about 240 "response tid" errors per timeout) and the BMC
panicked in dma_unmap_phys() as in the field report. With it, 1882
forced timeouts over 100 rounds on two buses gave no tid mismatches
or warnings, and MCTP traffic recovered after every round. A
100-cycle power-cycle soak of both hosts was also clean. The target
mode halt reset path is compile-tested only, since the BMC doesn't
run any I3C controller in target mode.
Fixes: 180e737c7747 ("i3c: master: Enhance error handling and reset mechanisms")
Google-Bug-Id: 586592800
Change-Id: I583f133e7b79597e48bbc9e2dc4b295635f75c71
Signed-off-by: Sam Agazaryan <samagazaryan@google.com>
1 file changed