aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRobin Murphy <robin.murphy@arm.com>2017-10-18 10:04:28 -0400
committerWill Deacon <will.deacon@arm.com>2017-10-20 11:55:10 -0400
commit8ff0f72371709889349a706e19bb38d9f71b1669 (patch)
tree29e961ad097c47c29ddbaf679e57ad4c2ba229dc /drivers
parenta529ea19aadb7a3bbcce3335ed4671adbe275b22 (diff)
iommu/arm-smmu-v3: Use burst-polling for sync completion
While CMD_SYNC is unlikely to complete immediately such that we never go round the polling loop, with a lightly-loaded queue it may still do so long before the delay period is up. If we have no better completion notifier, use similar logic as we have for SMMUv2 to spin a number of times before each backoff, so that we have more chance of catching syncs which complete relatively quickly and avoid delaying unnecessarily. Signed-off-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/iommu/arm-smmu-v3.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
index c148f76dd8e2..bfab719190e8 100644
--- a/drivers/iommu/arm-smmu-v3.c
+++ b/drivers/iommu/arm-smmu-v3.c
@@ -419,6 +419,7 @@
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_SYNC_TIMEOUT_US 1000000 /* 1s! */ 421#define ARM_SMMU_CMDQ_SYNC_TIMEOUT_US 1000000 /* 1s! */
422#define ARM_SMMU_CMDQ_SYNC_SPIN_COUNT 10
422 423
423#define MSI_IOVA_BASE 0x8000000 424#define MSI_IOVA_BASE 0x8000000
424#define MSI_IOVA_LENGTH 0x100000 425#define MSI_IOVA_LENGTH 0x100000
@@ -769,7 +770,7 @@ static void queue_inc_prod(struct arm_smmu_queue *q)
769static int queue_poll_cons(struct arm_smmu_queue *q, bool sync, bool wfe) 770static int queue_poll_cons(struct arm_smmu_queue *q, bool sync, bool wfe)
770{ 771{
771 ktime_t timeout; 772 ktime_t timeout;
772 unsigned int delay = 1; 773 unsigned int delay = 1, spin_cnt = 0;
773 774
774 /* Wait longer if it's a CMD_SYNC */ 775 /* Wait longer if it's a CMD_SYNC */
775 timeout = ktime_add_us(ktime_get(), sync ? 776 timeout = ktime_add_us(ktime_get(), sync ?
@@ -782,10 +783,13 @@ static int queue_poll_cons(struct arm_smmu_queue *q, bool sync, bool wfe)
782 783
783 if (wfe) { 784 if (wfe) {
784 wfe(); 785 wfe();
785 } else { 786 } else if (++spin_cnt < ARM_SMMU_CMDQ_SYNC_SPIN_COUNT) {
786 cpu_relax(); 787 cpu_relax();
788 continue;
789 } else {
787 udelay(delay); 790 udelay(delay);
788 delay *= 2; 791 delay *= 2;
792 spin_cnt = 0;
789 } 793 }
790 } 794 }
791 795