From patchwork Wed Aug 16 13:04:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 9903731 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 391E2600CA for ; Wed, 16 Aug 2017 13:05:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2ADD4289E5 for ; Wed, 16 Aug 2017 13:05:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E905289EB; Wed, 16 Aug 2017 13:05:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8C5DA289E5 for ; Wed, 16 Aug 2017 13:05:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=vbIjkrAHuk2T5S5UGFDPBlL+LJ3/BjoG4vGtvSt7icI=; b=fbRRg1LL2BAdm8 VOr6s+ZgPwdcd4J6YU13V7MwX1SdSg/7GJGmaIv1Rb3X0JuTB0dFgVIVO+w6eTDklrKmmNwu5gTIv F5BsjzwS7bxj364kii3lFBldELMEyRTWA0EkycarPbcWAS1Wh45Kd41A8VUML8YPe7xnLalrvC9Z6 u+mVwxDQki4SV47Hw/AYaeFaBEGriKxeWdJRZVpn8TuWw77MfFnuHC0oOLHdYCx+2WHH/y9K8NA3P nwDEaS7f6xUJqhZN1dE8WuAKZOq9TVDqfIV85h5vl6kWIVtDmZ/CRbyhJFhZ04fvTcVEurlST9Ccz p2Vn9bvrlAl2xDssjpFA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dhy0q-0004Eb-B2; Wed, 16 Aug 2017 13:05:32 +0000 Received: from szxga04-in.huawei.com ([45.249.212.190]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dhy0d-0002US-Es for linux-arm-kernel@lists.infradead.org; Wed, 16 Aug 2017 13:05:30 +0000 Received: from 172.30.72.60 (EHLO DGGEMS413-HUB.china.huawei.com) ([172.30.72.60]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DFG75847; Wed, 16 Aug 2017 21:04:48 +0800 (CST) Received: from localhost (10.177.19.219) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.301.0; Wed, 16 Aug 2017 21:04:42 +0800 From: Yang Yingliang To: , Subject: [PATCH] irqchip/gic-v3-its: handle queue wrapping in its_wait_for_range_completion() Date: Wed, 16 Aug 2017 21:04:42 +0800 Message-ID: <1502888682-12148-1-git-send-email-yangyingliang@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 X-Originating-IP: [10.177.19.219] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A010204.599442F0.0069, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: fa5011d6d3536741751f2659178e5321 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170816_060520_235809_7AA98E76 X-CRM114-Status: UNSURE ( 9.84 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;