From: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org> To: will.deacon-5wv7dgnIgG8@public.gmane.org Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org Subject: [RFT v3 3/3] iommu/arm-smmu-v3: Use burst-polling for sync completion Date: Wed, 18 Oct 2017 15:04:28 +0100 [thread overview] Message-ID: <5e8bbe01a33730541fac122b4b44709a1ca1e8d1.1508334262.git.robin.murphy@arm.com> (raw) In-Reply-To: <cover.1508334262.git.robin.murphy-5wv7dgnIgG8@public.gmane.org> 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-5wv7dgnIgG8@public.gmane.org> --- I still have no idea whether this patch has any real merit or not. drivers/iommu/arm-smmu-v3.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 3130e7182dde..994b3a38f222 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -418,6 +418,7 @@ /* High-level queue structures */ #define ARM_SMMU_POLL_TIMEOUT_US 100 #define ARM_SMMU_SYNC_TIMEOUT_US 1000000 /* 1s! */ +#define ARM_SMMU_SYNC_SPIN_COUNT 10 #define MSI_IOVA_BASE 0x8000000 #define MSI_IOVA_LENGTH 0x100000 @@ -1013,7 +1014,7 @@ static int arm_smmu_sync_poll_cons(struct arm_smmu_device *smmu, u32 sync_idx, ktime_t timeout = ktime_add_us(ktime_get(), ARM_SMMU_SYNC_TIMEOUT_US); struct arm_smmu_queue *q = &smmu->cmdq.q; bool wfe = !!(smmu->features & ARM_SMMU_FEAT_SEV); - unsigned int delay = 1; + unsigned int delay = 1, spin_cnt = 0; do { queue_sync_cons(q); @@ -1036,10 +1037,13 @@ static int arm_smmu_sync_poll_cons(struct arm_smmu_device *smmu, u32 sync_idx, if (wfe) { wfe(); - } else { + } else if (++spin_cnt < ARM_SMMU_SYNC_SPIN_COUNT) { cpu_relax(); + continue; + } else { udelay(delay); delay *= 2; + spin_cnt = 0; } } while (ktime_before(ktime_get(), timeout)); -- 2.13.4.dirty
WARNING: multiple messages have this Message-ID (diff)
From: robin.murphy@arm.com (Robin Murphy) To: linux-arm-kernel@lists.infradead.org Subject: [RFT v3 3/3] iommu/arm-smmu-v3: Use burst-polling for sync completion Date: Wed, 18 Oct 2017 15:04:28 +0100 [thread overview] Message-ID: <5e8bbe01a33730541fac122b4b44709a1ca1e8d1.1508334262.git.robin.murphy@arm.com> (raw) In-Reply-To: <cover.1508334262.git.robin.murphy@arm.com> 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> --- I still have no idea whether this patch has any real merit or not. drivers/iommu/arm-smmu-v3.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 3130e7182dde..994b3a38f222 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -418,6 +418,7 @@ /* High-level queue structures */ #define ARM_SMMU_POLL_TIMEOUT_US 100 #define ARM_SMMU_SYNC_TIMEOUT_US 1000000 /* 1s! */ +#define ARM_SMMU_SYNC_SPIN_COUNT 10 #define MSI_IOVA_BASE 0x8000000 #define MSI_IOVA_LENGTH 0x100000 @@ -1013,7 +1014,7 @@ static int arm_smmu_sync_poll_cons(struct arm_smmu_device *smmu, u32 sync_idx, ktime_t timeout = ktime_add_us(ktime_get(), ARM_SMMU_SYNC_TIMEOUT_US); struct arm_smmu_queue *q = &smmu->cmdq.q; bool wfe = !!(smmu->features & ARM_SMMU_FEAT_SEV); - unsigned int delay = 1; + unsigned int delay = 1, spin_cnt = 0; do { queue_sync_cons(q); @@ -1036,10 +1037,13 @@ static int arm_smmu_sync_poll_cons(struct arm_smmu_device *smmu, u32 sync_idx, if (wfe) { wfe(); - } else { + } else if (++spin_cnt < ARM_SMMU_SYNC_SPIN_COUNT) { cpu_relax(); + continue; + } else { udelay(delay); delay *= 2; + spin_cnt = 0; } } while (ktime_before(ktime_get(), timeout)); -- 2.13.4.dirty
next prev parent reply other threads:[~2017-10-18 14:04 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-10-18 14:04 [PATCH v3 0/3] SMMUv3 CMD_SYNC optimisation Robin Murphy 2017-10-18 14:04 ` Robin Murphy [not found] ` <cover.1508334262.git.robin.murphy-5wv7dgnIgG8@public.gmane.org> 2017-10-18 14:04 ` [PATCH v3 1/3] iommu/arm-smmu-v3: Use CMD_SYNC completion MSI Robin Murphy 2017-10-18 14:04 ` Robin Murphy 2017-10-18 14:04 ` [PATCH v3 2/3] iommu/arm-smmu-v3: Poll for CMD_SYNC outside cmdq lock Robin Murphy 2017-10-18 14:04 ` Robin Murphy [not found] ` <625ffbc273577515c324f6deea66a366e675b751.1508334262.git.robin.murphy-5wv7dgnIgG8@public.gmane.org> 2018-07-19 7:22 ` Leizhen (ThunderTown) 2018-07-19 7:22 ` Leizhen (ThunderTown) 2017-10-18 14:04 ` Robin Murphy [this message] 2017-10-18 14:04 ` [RFT v3 3/3] iommu/arm-smmu-v3: Use burst-polling for sync completion Robin Murphy
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=5e8bbe01a33730541fac122b4b44709a1ca1e8d1.1508334262.git.robin.murphy@arm.com \ --to=robin.murphy-5wv7dgnigg8@public.gmane.org \ --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \ --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \ --cc=will.deacon-5wv7dgnIgG8@public.gmane.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.