All of lore.kernel.org
 help / color / mirror / Atom feed
From: yangyingliang@huawei.com (Yang Yingliang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] irqchip/gic-v3-its: handle queue wrapping in its_wait_for_range_completion()
Date: Wed, 16 Aug 2017 21:04:42 +0800	[thread overview]
Message-ID: <1502888682-12148-1-git-send-email-yangyingliang@huawei.com> (raw)

If the to_idx wrap to 0, (rd_idx >= to_idx) will be true,
but the command is not completed.

When to_idx is smaller than from_idx, it means the queue
is wrapped. For handling this case, add ITS_CMD_QUEUE_SZ
to to_idx and rd_idx to.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/irqchip/irq-gic-v3-its.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 6893287..8e47515 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -446,13 +446,18 @@ static void its_wait_for_range_completion(struct its_node *its,
 					  struct its_cmd_block *to)
 {
 	u64 rd_idx, from_idx, to_idx;
+	u32 wrap_offset = 0;
 	u32 count = 1000000;	/* 1s! */
 
 	from_idx = its_cmd_ptr_to_offset(its, from);
 	to_idx = its_cmd_ptr_to_offset(its, to);
+	if (to_idx < from_idx) {
+		wrap_offset = ITS_CMD_QUEUE_SZ;
+		to_idx += ITS_CMD_QUEUE_SZ;
+	}
 
 	while (1) {
-		rd_idx = readl_relaxed(its->base + GITS_CREADR);
+		rd_idx = readl_relaxed(its->base + GITS_CREADR) + wrap_offset;
 		if (rd_idx >= to_idx || rd_idx < from_idx)
 			break;
 
-- 
2.5.0

             reply	other threads:[~2017-08-16 13:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-16 13:04 Yang Yingliang [this message]
2017-08-16 15:12 ` [PATCH] irqchip/gic-v3-its: handle queue wrapping in its_wait_for_range_completion() Marc Zyngier
2017-08-19  2:25   ` Yang Yingliang

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=1502888682-12148-1-git-send-email-yangyingliang@huawei.com \
    --to=yangyingliang@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.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.