Skip to content

Commit 2d178ba

Browse files
rmurphy-armSomasundaram Krishnasamy
authored andcommitted
iommu/arm-smmu-v3: Use burst-polling for sync completion
[ Upstream commit 8ff0f72 ] 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]> (cherry picked from commit 8ff0f72) Orabug: 30479048 Signed-off-by: Thomas Tai <[email protected]> Reviewed-by: Tom Saeger <[email protected]> Signed-off-by: Somasundaram Krishnasamy <[email protected]>
1 parent 0349fc7 commit 2d178ba

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
@@ -775,7 +776,7 @@ static void queue_inc_prod(struct arm_smmu_queue *q)
775776
static int queue_poll_cons(struct arm_smmu_queue *q, bool sync, bool wfe)
776777
{
777778
ktime_t timeout;
778-
unsigned int delay = 1;
779+
unsigned int delay = 1, spin_cnt = 0;
779780

780781
/* Wait longer if it's a CMD_SYNC */
781782
timeout = ktime_add_us(ktime_get(), sync ?
@@ -788,10 +789,13 @@ static int queue_poll_cons(struct arm_smmu_queue *q, bool sync, bool wfe)
788789

789790
if (wfe) {
790791
wfe();
791-
} else {
792+
} else if (++spin_cnt < ARM_SMMU_CMDQ_SYNC_SPIN_COUNT) {
792793
cpu_relax();
794+
continue;
795+
} else {
793796
udelay(delay);
794797
delay *= 2;
798+
spin_cnt = 0;
795799
}
796800
}
797801

0 commit comments

Comments
 (0)