From patchwork Fri May 5 11:17:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri X-Patchwork-Id: 9713413 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 5FF4460235 for ; Fri, 5 May 2017 11:18:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5DAAA28622 for ; Fri, 5 May 2017 11:18:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 52559286A0; Fri, 5 May 2017 11:18:45 +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 D3BF228622 for ; Fri, 5 May 2017 11:18:44 +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=mCDdQ+rWdCY9CfmeiSjsS6T1/865u3HxVfG1KjBS/dA=; b=E3I 2gsVBNJoaUGBEReCjwHezgHo4eVbaoDtXReb2vGtiPCoNJjfVo2t3fVOWfNGmXjFz4+OC7LMUz/km n4kno1sJ0ZsnJR8uhZu3LfJaBUEWpn440rvVxo9/DQmZeXZCaZTwDI7nxWn9i+E36RO+ldSaPJpme KB5hKUhQ8e3eltDdGIwMx5huV7gE44KNeC5uIIxiePlyBBT06310n9XtPStOVK09ETmJSRDfGMvFS DWSBGaf3syWML+QbZJeSzA0o0zmqZWIVRWA5OjTWvAtIh5vrxDOAITRUkK3aEFgVN73m1DrQOUPKY qsQkI0LW54EilBhcbeJqiS1d8jzr/2Q==; 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 1d6bFy-0007U4-Mt; Fri, 05 May 2017 11:18:42 +0000 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d6bFv-0007SS-Sn for linux-arm-kernel@lists.infradead.org; Fri, 05 May 2017 11:18:41 +0000 Received: by mail-pg0-x244.google.com with SMTP id u187so428611pgb.1 for ; Fri, 05 May 2017 04:18:19 -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=jUaqMQCg4W+Gpbo0VoXXnvMXc/uU30jUZeLKxIS0Q9E=; b=GZJuMpulWemMbmUTixJIYBR/4UgISkC5H+1A3c5hKDkmnRPmf+y4lcIVu8eoWGm0XR PvhA7rd7GQBH1u4kfOG6t6aLqhWvoXtPROtiI7JmTP7iErCqzeuZcTvEyJzyCtPClSGZ euLYuCtQ9IqmHYw8Qj9ML+83AKqQCuxBzrFS7EM/toYUoQi83Z/4coztQe0CjUPRuWHF dUA/rPgir/Fw19oEGvNnhYb/nqP4DuN3Djec59XyZ9ymlH1UsVklf60SO+Sd39/oHc7b O8FDH0vd63MpPJbdqiq1qzyencUSRuHAyaC5+srvqN9K7n7A0d8QlgXdDu6UMhQ2UtVD I1Ow== 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=jUaqMQCg4W+Gpbo0VoXXnvMXc/uU30jUZeLKxIS0Q9E=; b=G86T81hHPH5F7RBkPF9eBua0EN2+GZxCxDXBqVTcMkvXTLqb8Z1bbGAqu62pKwqZM7 kV/PG5EfqB628phuFik5PITqxK/N2KA73nNaifg9SZ9Otnwtz2hhO3g4jzsPgq1CN1SC UtjwA1bJsCMtMgADg2GFuNdyRo/kPBx/UScXxMY3xlTjgSEN2KQVx9FOdlkaniuNMO0O 5Au5MeQ+bC/89fnMyDuLft5Pl8UcZ2+v5/gPrHMAepI71Viq2jEorPYpy9azCYHjUvlA CbQnvq2Cq+dKbFNYAod0DWnni4tmWv01d0AVuRi28uq+V8ORUOMDfz71+Un8ZKwbSTYl /7AA== X-Gm-Message-State: AN3rC/7pawynILCcC6PLbtliPdkgQJRHznSkXvbsVhiu4iIQHi7QtYMc 4K+mbGniXrxJ8Q== X-Received: by 10.98.82.199 with SMTP id g190mr16112599pfb.132.1493983099293; Fri, 05 May 2017 04:18:19 -0700 (PDT) Received: from machine421.in.caveonetworks.com ([14.140.2.178]) by smtp.googlemail.com with ESMTPSA id t5sm2948832pgo.48.2017.05.05.04.18.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 May 2017 04:18:18 -0700 (PDT) From: sunil.kovvuri@gmail.com To: will.deacon@arm.com, robin.murphy@arm.com, iommu@lists.linux-foundation.org Subject: [PATCH v2] iommu/arm-smmu-v3: Increase CMDQ drain timeout value Date: Fri, 5 May 2017 16:47:46 +0530 Message-Id: <1493983066-28202-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-20170505_041839_950420_DAAF7CAF X-CRM114-Status: GOOD ( 12.58 ) 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, robert.richter@cavium.com, Sunil Goutham , linux-kernel@vger.kernel.org, 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 Processing queue full of TLB invalidation commands might take more time on some platforms than current timeout of 100us. So increased drain timeout value. Also now udelay time is increased exponentially for each poll. Signed-off-by: Sunil Goutham --- v2 - Addressed Will's and Robin's comments i.e increased poll timeout only for drain case and removed spin loop whose logic anyway is screwed up. - Also changed commit subject and message as this patch no longer exactly reflects what is done in SMMU driver i.e 8513c8930069 iommu/arm-smmu: Poll for TLB sync completion more effectively drivers/iommu/arm-smmu-v3.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index d412bdd..cbc8309 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -379,6 +379,8 @@ #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 + /* Event queue */ #define EVTQ_ENT_DWORDS 4 #define EVTQ_MAX_SZ_SHIFT 7 @@ -737,7 +739,12 @@ 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; + unsigned int delay = 1; + + /* Wait longer if it's queue drain */ + timeout = ktime_add_us(ktime_get(), drain ? CMDQ_DRAIN_TIMEOUT_US : + ARM_SMMU_POLL_TIMEOUT_US); while (queue_sync_cons(q), (drain ? !queue_empty(q) : queue_full(q))) { if (ktime_compare(ktime_get(), timeout) > 0) @@ -747,7 +754,11 @@ static int queue_poll_cons(struct arm_smmu_queue *q, bool drain, bool wfe) wfe(); } else { cpu_relax(); - udelay(1); + udelay(delay); + /* No point in sleeping for fixed time, + * if cons isn't moving fast. + */ + delay *= 2; } }