]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
iommu/riscv: Empty iommu queue before enabling it
authorXu Lu <luxu.kernel@bytedance.com>
Fri, 3 Jan 2025 09:32:19 +0000 (17:32 +0800)
committerJoerg Roedel <jroedel@suse.de>
Mon, 6 Jan 2025 11:37:19 +0000 (12:37 +0100)
Changing cqen/fqen/pqen from 0 to 1 sets the cqh/fqt/pqt registers to 0.
But the cqt/fqh/pqh registers are left unmodified. This commit resets
cqt/fqh/pqh registers to ensure corresponding queues are empty before
being enabled during initialization.

Signed-off-by: Xu Lu <luxu.kernel@bytedance.com>
Link: https://lore.kernel.org/r/20250103093220.38106-2-luxu.kernel@bytedance.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/riscv/iommu.c

index 8a05def774bdb5666091ab8d469bf1783d3da6f8..84806724f5680374542045b7cfb4bd82cc88c396 100644 (file)
@@ -240,6 +240,12 @@ static int riscv_iommu_queue_enable(struct riscv_iommu_device *iommu,
                return rc;
        }
 
+       /* Empty queue before enabling it */
+       if (queue->qid == RISCV_IOMMU_INTR_CQ)
+               riscv_iommu_writel(queue->iommu, Q_TAIL(queue), 0);
+       else
+               riscv_iommu_writel(queue->iommu, Q_HEAD(queue), 0);
+
        /*
         * Enable queue with interrupts, clear any memory fault if any.
         * Wait for the hardware to acknowledge request and activate queue