Skip to content

Commit 0349fc7

Browse files
wildea01Somasundaram Krishnasamy
authored andcommitted
iommu/arm-smmu-v3: Consolidate identical timeouts
[ Upstream commit a529ea1 ] We have separate (identical) timeout values for polling for a queue to drain and waiting for an MSI to signal CMD_SYNC completion. In reality, we only wait for the command queue to drain if we're waiting on a sync, so just merged these two timeouts into a single constant. Signed-off-by: Will Deacon <[email protected]> (cherry picked from commit a529ea1) Orabug: 30479048 Signed-off-by: Thomas Tai <[email protected]> Reviewed-by: Tom Saeger <[email protected]> Signed-off-by: Somasundaram Krishnasamy <[email protected]>
1 parent fd5015c commit 0349fc7

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

drivers/iommu/arm-smmu-v3.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,7 @@
418418

419419
/* High-level queue structures */
420420
#define ARM_SMMU_POLL_TIMEOUT_US 100
421-
#define ARM_SMMU_CMDQ_DRAIN_TIMEOUT_US 1000000 /* 1s! */
422-
#define ARM_SMMU_SYNC_TIMEOUT_US 1000000 /* 1s! */
421+
#define ARM_SMMU_CMDQ_SYNC_TIMEOUT_US 1000000 /* 1s! */
423422

424423
#define MSI_IOVA_BASE 0x8000000
425424
#define MSI_IOVA_LENGTH 0x100000
@@ -773,17 +772,17 @@ static void queue_inc_prod(struct arm_smmu_queue *q)
773772
* Wait for the SMMU to consume items. If drain is true, wait until the queue
774773
* is empty. Otherwise, wait until there is at least one free slot.
775774
*/
776-
static int queue_poll_cons(struct arm_smmu_queue *q, bool drain, bool wfe)
775+
static int queue_poll_cons(struct arm_smmu_queue *q, bool sync, bool wfe)
777776
{
778777
ktime_t timeout;
779778
unsigned int delay = 1;
780779

781-
/* Wait longer if it's queue drain */
782-
timeout = ktime_add_us(ktime_get(), drain ?
783-
ARM_SMMU_CMDQ_DRAIN_TIMEOUT_US :
780+
/* Wait longer if it's a CMD_SYNC */
781+
timeout = ktime_add_us(ktime_get(), sync ?
782+
ARM_SMMU_CMDQ_SYNC_TIMEOUT_US :
784783
ARM_SMMU_POLL_TIMEOUT_US);
785784

786-
while (queue_sync_cons(q), (drain ? !queue_empty(q) : queue_full(q))) {
785+
while (queue_sync_cons(q), (sync ? !queue_empty(q) : queue_full(q))) {
787786
if (ktime_compare(ktime_get(), timeout) > 0)
788787
return -ETIMEDOUT;
789788

@@ -992,10 +991,13 @@ static void arm_smmu_cmdq_issue_cmd(struct arm_smmu_device *smmu,
992991
*/
993992
static int __arm_smmu_sync_poll_msi(struct arm_smmu_device *smmu, u32 sync_idx)
994993
{
995-
ktime_t timeout = ktime_add_us(ktime_get(), ARM_SMMU_SYNC_TIMEOUT_US);
996-
u32 val = smp_cond_load_acquire(&smmu->sync_count,
997-
(int)(VAL - sync_idx) >= 0 ||
998-
!ktime_before(ktime_get(), timeout));
994+
ktime_t timeout;
995+
u32 val;
996+
997+
timeout = ktime_add_us(ktime_get(), ARM_SMMU_CMDQ_SYNC_TIMEOUT_US);
998+
val = smp_cond_load_acquire(&smmu->sync_count,
999+
(int)(VAL - sync_idx) >= 0 ||
1000+
!ktime_before(ktime_get(), timeout));
9991001

10001002
return (int)(val - sync_idx) < 0 ? -ETIMEDOUT : 0;
10011003
}

0 commit comments

Comments
 (0)