Skip to content

Commit 8ff0f72

Browse files
rmurphy-armwildea01
authored andcommitted
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 <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent a529ea1 commit 8ff0f72

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/iommu/arm-smmu-v3.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@
419419
/* High-level queue structures */
420420
#define ARM_SMMU_POLL_TIMEOUT_US 100
421421
#define ARM_SMMU_CMDQ_SYNC_TIMEOUT_US 1000000 /* 1s! */
422+
#define ARM_SMMU_CMDQ_SYNC_SPIN_COUNT 10
422423

423424
#define MSI_IOVA_BASE 0x8000000
424425
#define MSI_IOVA_LENGTH 0x100000
@@ -769,7 +770,7 @@ static void queue_inc_prod(struct arm_smmu_queue *q)
769770
static int queue_poll_cons(struct arm_smmu_queue *q, bool sync, bool wfe)
770771
{
771772
ktime_t timeout;
772-
unsigned int delay = 1;
773+
unsigned int delay = 1, spin_cnt = 0;
773774

774775
/* Wait longer if it's a CMD_SYNC */
775776
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)
782783

783784
if (wfe) {
784785
wfe();
785-
} else {
786+
} else if (++spin_cnt < ARM_SMMU_CMDQ_SYNC_SPIN_COUNT) {
786787
cpu_relax();
788+
continue;
789+
} else {
787790
udelay(delay);
788791
delay *= 2;
792+
spin_cnt = 0;
789793
}
790794
}
791795

0 commit comments

Comments
 (0)