From: Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>
To: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>
Cc: Sunil Goutham <sgoutham-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>,
jcm-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
robert.richter-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
Geetha <gakula-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>,
sunil.kovvuri-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH] iommu/arm-smmu-v3: Poll for CMDQ drain completion more effectively
Date: Wed, 3 May 2017 16:40:46 +0100 [thread overview]
Message-ID: <20170503154046.GQ8233@arm.com> (raw)
In-Reply-To: <a9d1bb4d-6578-93bb-66cf-5ed55952b85a-5wv7dgnIgG8@public.gmane.org>
On Wed, May 03, 2017 at 04:33:57PM +0100, Robin Murphy wrote:
> On 27/04/17 12:13, sunil.kovvuri-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
> > From: Sunil Goutham <sgoutham-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
> >
> > Modified polling on CMDQ consumer similar to how polling is done for TLB SYNC
> > completion in SMMUv2 driver. Code changes are done with reference to
> >
> > 8513c8930069 iommu/arm-smmu: Poll for TLB sync completion more effectively
> >
> > Poll timeout has been increased which addresses issue of 100us timeout not
> > sufficient, when command queue is full with TLB invalidation commands.
> >
> > Signed-off-by: Sunil Goutham <sgoutham-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
> > Signed-off-by: Geetha <gakula-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
> > ---
> > drivers/iommu/arm-smmu-v3.c | 15 ++++++++++++---
> > 1 file changed, 12 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
> > index d412bdd..34599d4 100644
> > --- a/drivers/iommu/arm-smmu-v3.c
> > +++ b/drivers/iommu/arm-smmu-v3.c
> > @@ -379,6 +379,9 @@
> > #define CMDQ_SYNC_0_CS_NONE (0UL << CMDQ_SYNC_0_CS_SHIFT)
> > #define CMDQ_SYNC_0_CS_SEV (2UL << CMDQ_SYNC_0_CS_SHIFT)
> >
> > +#define CMDQ_DRAIN_TIMEOUT_US 1000
> > +#define CMDQ_SPIN_COUNT 10
> > +
> > /* Event queue */
> > #define EVTQ_ENT_DWORDS 4
> > #define EVTQ_MAX_SZ_SHIFT 7
> > @@ -737,7 +740,8 @@ static void queue_inc_prod(struct arm_smmu_queue *q)
> > */
> > static int queue_poll_cons(struct arm_smmu_queue *q, bool drain, bool wfe)
> > {
> > - ktime_t timeout = ktime_add_us(ktime_get(), ARM_SMMU_POLL_TIMEOUT_US);
> > + ktime_t timeout = ktime_add_us(ktime_get(), CMDQ_DRAIN_TIMEOUT_US);
> > + unsigned int spin_cnt, delay = 1;
> >
> > while (queue_sync_cons(q), (drain ? !queue_empty(q) : queue_full(q))) {
> > if (ktime_compare(ktime_get(), timeout) > 0)
> > @@ -746,8 +750,13 @@ static int queue_poll_cons(struct arm_smmu_queue *q, bool drain, bool wfe)
> > if (wfe) {
> > wfe();
> > } else {
> > - cpu_relax();
> > - udelay(1);
> > + for (spin_cnt = 0;
> > + spin_cnt < CMDQ_SPIN_COUNT; spin_cnt++) {
> > + cpu_relax();
> > + continue;
> > + }
> > + udelay(delay);
> > + delay *= 2;
>
> Sorry, I can't make sense of this. The referenced commit uses the spin
> loop to poll opportunistically a few times before delaying. This loop
> just adds a short open-coded udelay to an exponential udelay, and it's
> not really clear that that's any better than a fixed udelay (especially
> as the two cases in which we poll are somewhat different).
>
> What's wrong with simply increasing the timeout value alone?
I asked that the timeout is only increased for the drain case, and that
we fix the issue here where we udelat if cons didn't move immediately:
http://lists.infradead.org/pipermail/linux-arm-kernel/2017-April/503389.html
but I don't think the patch above actually achieves any of that.
Will
WARNING: multiple messages have this Message-ID (diff)
From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] iommu/arm-smmu-v3: Poll for CMDQ drain completion more effectively
Date: Wed, 3 May 2017 16:40:46 +0100 [thread overview]
Message-ID: <20170503154046.GQ8233@arm.com> (raw)
In-Reply-To: <a9d1bb4d-6578-93bb-66cf-5ed55952b85a@arm.com>
On Wed, May 03, 2017 at 04:33:57PM +0100, Robin Murphy wrote:
> On 27/04/17 12:13, sunil.kovvuri at gmail.com wrote:
> > From: Sunil Goutham <sgoutham@cavium.com>
> >
> > Modified polling on CMDQ consumer similar to how polling is done for TLB SYNC
> > completion in SMMUv2 driver. Code changes are done with reference to
> >
> > 8513c8930069 iommu/arm-smmu: Poll for TLB sync completion more effectively
> >
> > Poll timeout has been increased which addresses issue of 100us timeout not
> > sufficient, when command queue is full with TLB invalidation commands.
> >
> > Signed-off-by: Sunil Goutham <sgoutham@cavium.com>
> > Signed-off-by: Geetha <gakula@cavium.com>
> > ---
> > drivers/iommu/arm-smmu-v3.c | 15 ++++++++++++---
> > 1 file changed, 12 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
> > index d412bdd..34599d4 100644
> > --- a/drivers/iommu/arm-smmu-v3.c
> > +++ b/drivers/iommu/arm-smmu-v3.c
> > @@ -379,6 +379,9 @@
> > #define CMDQ_SYNC_0_CS_NONE (0UL << CMDQ_SYNC_0_CS_SHIFT)
> > #define CMDQ_SYNC_0_CS_SEV (2UL << CMDQ_SYNC_0_CS_SHIFT)
> >
> > +#define CMDQ_DRAIN_TIMEOUT_US 1000
> > +#define CMDQ_SPIN_COUNT 10
> > +
> > /* Event queue */
> > #define EVTQ_ENT_DWORDS 4
> > #define EVTQ_MAX_SZ_SHIFT 7
> > @@ -737,7 +740,8 @@ static void queue_inc_prod(struct arm_smmu_queue *q)
> > */
> > static int queue_poll_cons(struct arm_smmu_queue *q, bool drain, bool wfe)
> > {
> > - ktime_t timeout = ktime_add_us(ktime_get(), ARM_SMMU_POLL_TIMEOUT_US);
> > + ktime_t timeout = ktime_add_us(ktime_get(), CMDQ_DRAIN_TIMEOUT_US);
> > + unsigned int spin_cnt, delay = 1;
> >
> > while (queue_sync_cons(q), (drain ? !queue_empty(q) : queue_full(q))) {
> > if (ktime_compare(ktime_get(), timeout) > 0)
> > @@ -746,8 +750,13 @@ static int queue_poll_cons(struct arm_smmu_queue *q, bool drain, bool wfe)
> > if (wfe) {
> > wfe();
> > } else {
> > - cpu_relax();
> > - udelay(1);
> > + for (spin_cnt = 0;
> > + spin_cnt < CMDQ_SPIN_COUNT; spin_cnt++) {
> > + cpu_relax();
> > + continue;
> > + }
> > + udelay(delay);
> > + delay *= 2;
>
> Sorry, I can't make sense of this. The referenced commit uses the spin
> loop to poll opportunistically a few times before delaying. This loop
> just adds a short open-coded udelay to an exponential udelay, and it's
> not really clear that that's any better than a fixed udelay (especially
> as the two cases in which we poll are somewhat different).
>
> What's wrong with simply increasing the timeout value alone?
I asked that the timeout is only increased for the drain case, and that
we fix the issue here where we udelat if cons didn't move immediately:
http://lists.infradead.org/pipermail/linux-arm-kernel/2017-April/503389.html
but I don't think the patch above actually achieves any of that.
Will
WARNING: multiple messages have this Message-ID (diff)
From: Will Deacon <will.deacon@arm.com>
To: Robin Murphy <robin.murphy@arm.com>
Cc: sunil.kovvuri@gmail.com, iommu@lists.linux-foundation.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, robert.richter@cavium.com,
jcm@redhat.com, Sunil Goutham <sgoutham@cavium.com>,
Geetha <gakula@cavium.com>
Subject: Re: [PATCH] iommu/arm-smmu-v3: Poll for CMDQ drain completion more effectively
Date: Wed, 3 May 2017 16:40:46 +0100 [thread overview]
Message-ID: <20170503154046.GQ8233@arm.com> (raw)
In-Reply-To: <a9d1bb4d-6578-93bb-66cf-5ed55952b85a@arm.com>
On Wed, May 03, 2017 at 04:33:57PM +0100, Robin Murphy wrote:
> On 27/04/17 12:13, sunil.kovvuri@gmail.com wrote:
> > From: Sunil Goutham <sgoutham@cavium.com>
> >
> > Modified polling on CMDQ consumer similar to how polling is done for TLB SYNC
> > completion in SMMUv2 driver. Code changes are done with reference to
> >
> > 8513c8930069 iommu/arm-smmu: Poll for TLB sync completion more effectively
> >
> > Poll timeout has been increased which addresses issue of 100us timeout not
> > sufficient, when command queue is full with TLB invalidation commands.
> >
> > Signed-off-by: Sunil Goutham <sgoutham@cavium.com>
> > Signed-off-by: Geetha <gakula@cavium.com>
> > ---
> > drivers/iommu/arm-smmu-v3.c | 15 ++++++++++++---
> > 1 file changed, 12 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
> > index d412bdd..34599d4 100644
> > --- a/drivers/iommu/arm-smmu-v3.c
> > +++ b/drivers/iommu/arm-smmu-v3.c
> > @@ -379,6 +379,9 @@
> > #define CMDQ_SYNC_0_CS_NONE (0UL << CMDQ_SYNC_0_CS_SHIFT)
> > #define CMDQ_SYNC_0_CS_SEV (2UL << CMDQ_SYNC_0_CS_SHIFT)
> >
> > +#define CMDQ_DRAIN_TIMEOUT_US 1000
> > +#define CMDQ_SPIN_COUNT 10
> > +
> > /* Event queue */
> > #define EVTQ_ENT_DWORDS 4
> > #define EVTQ_MAX_SZ_SHIFT 7
> > @@ -737,7 +740,8 @@ static void queue_inc_prod(struct arm_smmu_queue *q)
> > */
> > static int queue_poll_cons(struct arm_smmu_queue *q, bool drain, bool wfe)
> > {
> > - ktime_t timeout = ktime_add_us(ktime_get(), ARM_SMMU_POLL_TIMEOUT_US);
> > + ktime_t timeout = ktime_add_us(ktime_get(), CMDQ_DRAIN_TIMEOUT_US);
> > + unsigned int spin_cnt, delay = 1;
> >
> > while (queue_sync_cons(q), (drain ? !queue_empty(q) : queue_full(q))) {
> > if (ktime_compare(ktime_get(), timeout) > 0)
> > @@ -746,8 +750,13 @@ static int queue_poll_cons(struct arm_smmu_queue *q, bool drain, bool wfe)
> > if (wfe) {
> > wfe();
> > } else {
> > - cpu_relax();
> > - udelay(1);
> > + for (spin_cnt = 0;
> > + spin_cnt < CMDQ_SPIN_COUNT; spin_cnt++) {
> > + cpu_relax();
> > + continue;
> > + }
> > + udelay(delay);
> > + delay *= 2;
>
> Sorry, I can't make sense of this. The referenced commit uses the spin
> loop to poll opportunistically a few times before delaying. This loop
> just adds a short open-coded udelay to an exponential udelay, and it's
> not really clear that that's any better than a fixed udelay (especially
> as the two cases in which we poll are somewhat different).
>
> What's wrong with simply increasing the timeout value alone?
I asked that the timeout is only increased for the drain case, and that
we fix the issue here where we udelat if cons didn't move immediately:
http://lists.infradead.org/pipermail/linux-arm-kernel/2017-April/503389.html
but I don't think the patch above actually achieves any of that.
Will
next prev parent reply other threads:[~2017-05-03 15:40 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-27 11:13 [PATCH] iommu/arm-smmu-v3: Poll for CMDQ drain completion more effectively sunil.kovvuri-Re5JQEeQqe8AvxtiuMwx3w
2017-04-27 11:13 ` sunil.kovvuri
2017-04-27 11:13 ` sunil.kovvuri at gmail.com
[not found] ` <1493291587-23488-1-git-send-email-sunil.kovvuri-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-05-03 13:19 ` Sunil Kovvuri
2017-05-03 13:19 ` Sunil Kovvuri
2017-05-03 13:19 ` Sunil Kovvuri
2017-05-03 15:37 ` Will Deacon
2017-05-03 15:37 ` Will Deacon
2017-05-03 15:54 ` Sunil Kovvuri
2017-05-03 15:54 ` Sunil Kovvuri
2017-05-03 15:59 ` Will Deacon
2017-05-03 15:59 ` Will Deacon
[not found] ` <20170503155920.GT8233-5wv7dgnIgG8@public.gmane.org>
2017-05-03 16:24 ` Sunil Kovvuri
2017-05-03 16:24 ` Sunil Kovvuri
2017-05-03 16:24 ` Sunil Kovvuri
2017-05-03 15:33 ` Robin Murphy
2017-05-03 15:33 ` Robin Murphy
[not found] ` <a9d1bb4d-6578-93bb-66cf-5ed55952b85a-5wv7dgnIgG8@public.gmane.org>
2017-05-03 15:40 ` Will Deacon [this message]
2017-05-03 15:40 ` Will Deacon
2017-05-03 15:40 ` Will Deacon
[not found] ` <20170503154046.GQ8233-5wv7dgnIgG8@public.gmane.org>
2017-05-03 16:23 ` Sunil Kovvuri
2017-05-03 16:23 ` Sunil Kovvuri
2017-05-03 16:23 ` Sunil Kovvuri
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=20170503154046.GQ8233@arm.com \
--to=will.deacon-5wv7dgnigg8@public.gmane.org \
--cc=gakula-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=jcm-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=robert.richter-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org \
--cc=robin.murphy-5wv7dgnIgG8@public.gmane.org \
--cc=sgoutham-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org \
--cc=sunil.kovvuri-Re5JQEeQqe8AvxtiuMwx3w@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: link
Be 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.