]> git.ipfire.org Git - thirdparty/linux.git/commit
i3c: mipi-i3c-hci: Fix race in DMA ring enqueue for parallel xfers
authorAdrian Hunter <adrian.hunter@intel.com>
Fri, 6 Mar 2026 07:24:42 +0000 (09:24 +0200)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Wed, 11 Mar 2026 21:10:01 +0000 (22:10 +0100)
commit4decbbc8a8cf0a69ab011d7c2c88ed3cd0a00ddd
tree65cceb5250fad6fbaecf3f483743626e3046d907
parentfa12bb903bc3ed1826e355d267fe134bde95e23c
i3c: mipi-i3c-hci: Fix race in DMA ring enqueue for parallel xfers

The I3C subsystem allows multiple transfers to be queued concurrently.
However, the MIPI I3C HCI driver's DMA enqueue path, hci_dma_queue_xfer(),
lacks sufficient serialization.

In particular, the allocation of the enqueue_ptr and its subsequent update
in the RING_OPERATION1 register, must be done atomically.  Otherwise, for
example, it would be possible for 2 transfers to be allocated the same
enqueue_ptr.

Extend the use of the existing spinlock for that purpose.  Keep a count of
the number of xfers enqueued so that it is easy to determine if the ring
has enough space.

Fixes: 9ad9a52cce282 ("i3c/master: introduce the mipi-i3c-hci driver")
Cc: stable@vger.kernel.org
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20260306072451.11131-6-adrian.hunter@intel.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/i3c/master/mipi-i3c-hci/dma.c