[PATCH 0/3] iommu/riscv: Fix command queue publishing races
| Newsgroups | org.infradead.lists.linux-riscv,dev.linux.lists.iommu,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
From: Fangyu Yu <[email protected]> This series fixes races in the RISC-V IOMMU command queue submission path. The current command queue code reserves a producer index before the command is written and before the hardware tail is updated. Multiple CPUs can therefore reserve different producer indexes concurrently and then wait for the software tail to reach their index before publishing their own command. That model is fragile when a command submission fails after reserving an index. The failed producer index is never published, so later submitters can wait behind a hole in the software producer stream. This can also lead to misleading IOFENCE.C completion timeouts, because the sync path may wait for a producer index whose command was never actually enqueued. Fix this by serializing command queue publishing with a raw spinlock. Instead of reserving producer indexes ahead of time, the submission path uses the current software tail as the next command index, writes the command, publishes the hardware tail, and then advances the software tail while holding the lock. When the command queue is full, the code drops the lock and waits for hardware consumption before retrying, so other CPUs are not blocked behind a long hardware poll. The final patch changes the queue submission helper to return an error when enqueue fails. The IOFENCE.C sync path then avoids waiting for a command that was never published to hardware. This series does not attempt to add full RAS/error recovery for command queue failures. It keeps the existing local error reporting behavior and only fixes the software queue state and wait semantics. Fangyu Yu (3): iommu/riscv: Add command queue lock iommu/riscv: Serialize command queue publishing iommu/riscv: Avoid waiting on failed command enqueue drivers/iommu/riscv/iommu.c | 121 ++++++++++++++++++++++-------------- drivers/iommu/riscv/iommu.h | 2 + 2 files changed, 76 insertions(+), 47 deletions(-) -- 2.50.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv