From patchwork Thu Apr 27 11:13:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri X-Patchwork-Id: 9702755 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 4BC5A603F7 for ; Thu, 27 Apr 2017 11:14:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D7B3285E5 for ; Thu, 27 Apr 2017 11:14:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 408032860C; Thu, 27 Apr 2017 11:14:05 +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=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM 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 9613F285E5 for ; Thu, 27 Apr 2017 11:14:04 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=JkvBdE3brPfW84GWWTCKSy3Pqi2p635Jzvj9NhAdCi0=; b=R4c AKv/Hw9tPqO/WsZkaDwPqP0IJFD/K8orJmEApg9m2T9lhjLFVc7YQjk/HVvlx3sXFwGBXOCWqTqze M9HzGpo5VwuBExTep4DdOdAbfj82zsh1vGGbBeG8XE/DG6/lmJnEvs48Y5F0iSnt7WqCXLnaDqCoX GUagH9gtgH9Lyk/ZOC2d0GQ3fK/oVTU5PDumgitByFzL9aTV1yriEgFK3aYkGgboPuEK1ebOyw5E+ BECJoceJj0UhUQeE7B78yGQweFoRMZjpcuzN91KccPv+y+gT87mgs9C6mPmCFlfRWgZhoSKv1yd9C iZ6wu+hBCfLq13i2L+V43dhs0m/akPg==; 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 1d3hN5-0003B6-KV; Thu, 27 Apr 2017 11:14:03 +0000 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d3hN2-00038l-2e for linux-arm-kernel@lists.infradead.org; Thu, 27 Apr 2017 11:14:01 +0000 Received: by mail-pf0-x244.google.com with SMTP id g23so9106218pfj.1 for ; Thu, 27 Apr 2017 04:13:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=df3mBcLBycQJeR2w/7aT4A+M99Y1EsClNHZ8UMYPkOM=; b=Rh4YCy3oHoGg103KLFUyzfx6KMmjJ1Wf1VqP/Er182h1LC8e3ezXbxCuokrZKD+5u7 2cSaUNOmMFrdhUoNgVADlWHpYnOKrklGjBjZLWgljyJb02O4+iYkHFm7/2f6Cm95CpEJ Vk8yBrDMBw6c3kPyl/ZOo7jhCSXAPhmnytVBBPcj+mozP+DInHIFnByPbSDjppferEVp 7rubdMMT1oJCeppcf3v01iSnyPjLUClvnEuWQIrqs3eh72ZfTYVV1psi4k2h5ljAL07O uEB9iqh8WVIVi+IC6CD9evHStYHFAAEyqLkVx3icB8EqdHyLh9Q0iI01UXTrxSeI7DuR 35/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=df3mBcLBycQJeR2w/7aT4A+M99Y1EsClNHZ8UMYPkOM=; b=a3lUFzbhQJ+pRtOB3eAjIB4N1fJCAtkv3CY0MB10YLpeP+p4sDrJ2WnjYDQc6tTP7c AYLShvOsDPUgYF1OogiJubg4Ue4DRBBdMsVe3gKMYQYSd0EBGu5aG0A4n7Dqf10KDB/e 9Mt79MmxTmwEoa/plwKViIrnBDoMdpfx5fyx5xHm36rBbImdYTjacEIyXzODH3vU2l/N Bj3Q5haBbYr4YC+JY8rS3KimBpxvebqDBeiHtC5UVLNWikL67rS0o4RgIAppjiGojqli oQvB4Onta9QL+tMQtk6oUU4tbay9cTvJaOZKsIZk3SI+7oR6zKIlVx5BF0deVoGM1cev cvZg== X-Gm-Message-State: AN3rC/6qecd01fdK0DBamLBYj4prUq6jGCD+eKaZvNrmN57z5/DCk550 kZFiz8sGQYhWrA== X-Received: by 10.84.215.218 with SMTP id g26mr6555949plj.22.1493291618761; Thu, 27 Apr 2017 04:13:38 -0700 (PDT) Received: from machine421.in.caveonetworks.com ([14.140.2.178]) by smtp.googlemail.com with ESMTPSA id e185sm3741571pfa.115.2017.04.27.04.13.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Apr 2017 04:13:37 -0700 (PDT) From: sunil.kovvuri@gmail.com To: will.deacon@arm.com, robin.murphy@arm.com, iommu@lists.linux-foundation.org Subject: [PATCH] iommu/arm-smmu-v3: Poll for CMDQ drain completion more effectively Date: Thu, 27 Apr 2017 16:43:07 +0530 Message-Id: <1493291587-23488-1-git-send-email-sunil.kovvuri@gmail.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170427_041400_254161_06586F85 X-CRM114-Status: GOOD ( 11.10 ) 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: , Cc: jcm@redhat.com, linux-kernel@vger.kernel.org, robert.richter@cavium.com, Geetha , Sunil Goutham , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 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 From: Sunil Goutham 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 Signed-off-by: Geetha --- 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; } }