summaryrefslogtreecommitdiffstats
path: root/drivers/iommu/arm-smmu-v3.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/iommu/arm-smmu-v3.c')
-rw-r--r--drivers/iommu/arm-smmu-v3.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
index 3876a0328589..c148f76dd8e2 100644
--- a/drivers/iommu/arm-smmu-v3.c
+++ b/drivers/iommu/arm-smmu-v3.c
@@ -418,8 +418,7 @@
418 418
419/* High-level queue structures */ 419/* High-level queue structures */
420#define ARM_SMMU_POLL_TIMEOUT_US 100 420#define ARM_SMMU_POLL_TIMEOUT_US 100
421#define ARM_SMMU_CMDQ_DRAIN_TIMEOUT_US 1000000 /* 1s! */ 421#define ARM_SMMU_CMDQ_SYNC_TIMEOUT_US 1000000 /* 1s! */
422#define ARM_SMMU_SYNC_TIMEOUT_US 1000000 /* 1s! */
423 422
424#define MSI_IOVA_BASE 0x8000000 423#define MSI_IOVA_BASE 0x8000000
425#define MSI_IOVA_LENGTH 0x100000 424#define MSI_IOVA_LENGTH 0x100000
@@ -767,17 +766,17 @@ static void queue_inc_prod(struct arm_smmu_queue *q)
767 * Wait for the SMMU to consume items. If drain is true, wait until the queue 766 * Wait for the SMMU to consume items. If drain is true, wait until the queue
768 * is empty. Otherwise, wait until there is at least one free slot. 767 * is empty. Otherwise, wait until there is at least one free slot.
769 */ 768 */
770static int queue_poll_cons(struct arm_smmu_queue *q, bool drain, bool wfe) 769static int queue_poll_cons(struct arm_smmu_queue *q, bool sync, bool wfe)
771{ 770{
772 ktime_t timeout; 771 ktime_t timeout;
773 unsigned int delay = 1; 772 unsigned int delay = 1;
774 773
775 /* Wait longer if it's queue drain */ 774 /* Wait longer if it's a CMD_SYNC */
776 timeout = ktime_add_us(ktime_get(), drain ? 775 timeout = ktime_add_us(ktime_get(), sync ?
777 ARM_SMMU_CMDQ_DRAIN_TIMEOUT_US : 776 ARM_SMMU_CMDQ_SYNC_TIMEOUT_US :
778 ARM_SMMU_POLL_TIMEOUT_US); 777 ARM_SMMU_POLL_TIMEOUT_US);
779 778
780 while (queue_sync_cons(q), (drain ? !queue_empty(q) : queue_full(q))) { 779 while (queue_sync_cons(q), (sync ? !queue_empty(q) : queue_full(q))) {
781 if (ktime_compare(ktime_get(), timeout) > 0) 780 if (ktime_compare(ktime_get(), timeout) > 0)
782 return -ETIMEDOUT; 781 return -ETIMEDOUT;
783 782
@@ -986,10 +985,13 @@ static void arm_smmu_cmdq_issue_cmd(struct arm_smmu_device *smmu,
986 */ 985 */
987static int __arm_smmu_sync_poll_msi(struct arm_smmu_device *smmu, u32 sync_idx) 986static int __arm_smmu_sync_poll_msi(struct arm_smmu_device *smmu, u32 sync_idx)
988{ 987{
989 ktime_t timeout = ktime_add_us(ktime_get(), ARM_SMMU_SYNC_TIMEOUT_US); 988 ktime_t timeout;
990 u32 val = smp_cond_load_acquire(&smmu->sync_count, 989 u32 val;
991 (int)(VAL - sync_idx) >= 0 || 990
992 !ktime_before(ktime_get(), timeout)); 991 timeout = ktime_add_us(ktime_get(), ARM_SMMU_CMDQ_SYNC_TIMEOUT_US);
992 val = smp_cond_load_acquire(&smmu->sync_count,
993 (int)(VAL - sync_idx) >= 0 ||
994 !ktime_before(ktime_get(), timeout));
993 995
994 return (int)(val - sync_idx) < 0 ? -ETIMEDOUT : 0; 996 return (int)(val - sync_idx) < 0 ? -ETIMEDOUT : 0;
995} 997}