Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1929109rwd; Fri, 2 Jun 2023 02:09:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ78kM+P4yIlfc40xgzvYeCL6186Exg61hym6wAggtR4PgYWAXQaxDUcFbVa3ONPBXATZFA6 X-Received: by 2002:a05:620a:2541:b0:75b:23a0:d9e9 with SMTP id s1-20020a05620a254100b0075b23a0d9e9mr12034587qko.63.1685696943998; Fri, 02 Jun 2023 02:09:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685696943; cv=none; d=google.com; s=arc-20160816; b=z6F4aqZRdHC30W5R/6Y+KA98QzLvdVXyh46JdcZPKRHmr8rscI4WrN0r99gtOcQSXk DPHA5yMygeDkXvhBj+Zs3eque1BW7+Fs8R88Jl1IFkJacOkBUrU4mM4ucZaXhWNeGwCU o8Pc5zZbabQ076LVm9DGNN77nbAXWBhwze7TqFizqftNaofCd8MXH7QYWkCCe4zC/68l dIVQOgePf75nUv9dfGtXtgkMTgU78+eBC7s/EbGfBa8POADh0H+N9BSUzinDVxB9pVoi BLosOwQuwR8xJliZSW5bzV2jdLB/U/G4Dpcq/OjTHPVCkyXelykzeTiidHqrZe5mJQqZ 9Tgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=55LrKU5QMRHVfRj7TFz49ZLxEXVnIs/Yp9ekfsZZUM8=; b=SdwY2OFV5cmw1WWAt3Z7W55YCjzvZtfXV5e/wjRaaT7y+Ldld222/JQOzEEfixsCw4 qUUfqZA9BpO7tPZPrhhZ2OGHWUNVY0CWj0CTkLeEE7bqcWPvZqC+hdCFAZeD8cbsl0KE HjvA4Gy/XUsw+dZdW469483RTseBiFrh+1FUIitst3KV3oDHjoGAJfL8vFc/gvutDlPl S90SgxSvBtVn5qGmFZhgDJkXExWNqZQe/rWzn59DykW7JS4YAB/Jy1BjPHyF9KyNBcfQ v/z+YAe2fCH7F56S67Qan8HPcb2luGtb5nUAL2ITV2bx4In/wKM1MB1gAsly4hxsH1gj Salw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x3-20020aa79403000000b006515278f780si446840pfo.132.2023.06.02.02.08.50; Fri, 02 Jun 2023 02:09:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235012AbjFBIwm (ORCPT + 99 others); Fri, 2 Jun 2023 04:52:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234911AbjFBIv7 (ORCPT ); Fri, 2 Jun 2023 04:51:59 -0400 Received: from laurent.telenet-ops.be (laurent.telenet-ops.be [IPv6:2a02:1800:110:4::f00:19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A3EE1734 for ; Fri, 2 Jun 2023 01:51:16 -0700 (PDT) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed30:158c:2ccf:1f70:e136]) by laurent.telenet-ops.be with bizsmtp id 48qo2A00F1tRZS8018qoyb; Fri, 02 Jun 2023 10:51:14 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1q50UP-00BhYW-0P; Fri, 02 Jun 2023 10:50:48 +0200 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1q50Ui-00APxr-3g; Fri, 02 Jun 2023 10:50:48 +0200 From: Geert Uytterhoeven To: Michael Turquette , Stephen Boyd , Yoshihiro Shimoda , Magnus Damm , Joerg Roedel , Robin Murphy Cc: Tomasz Figa , Sylwester Nawrocki , Will Deacon , Arnd Bergmann , Wolfram Sang , Dejin Zheng , Kai-Heng Feng , Nicholas Piggin , Heiko Carstens , Peter Zijlstra , Russell King , John Stultz , Thomas Gleixner , Tony Lindgren , Krzysztof Kozlowski , Tero Kristo , Ulf Hansson , "Rafael J . Wysocki" , Vincent Guittot , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-pm@vger.kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v3 7/7] iommu/ipmmu-vmsa: Convert to read_poll_timeout_atomic() Date: Fri, 2 Jun 2023 10:50:42 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use read_poll_timeout_atomic() instead of open-coding the same operation. Signed-off-by: Geert Uytterhoeven --- v3: - New. --- drivers/iommu/ipmmu-vmsa.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c index 9f64c5c9f5b90ace..3b58a8ea3bdef190 100644 --- a/drivers/iommu/ipmmu-vmsa.c +++ b/drivers/iommu/ipmmu-vmsa.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -253,17 +254,13 @@ static void ipmmu_imuctr_write(struct ipmmu_vmsa_device *mmu, /* Wait for any pending TLB invalidations to complete */ static void ipmmu_tlb_sync(struct ipmmu_vmsa_domain *domain) { - unsigned int count = 0; + u32 val; - while (ipmmu_ctx_read_root(domain, IMCTR) & IMCTR_FLUSH) { - cpu_relax(); - if (++count == TLB_LOOP_TIMEOUT) { - dev_err_ratelimited(domain->mmu->dev, + if (read_poll_timeout_atomic(ipmmu_ctx_read_root, val, + !(val & IMCTR_FLUSH), 1, TLB_LOOP_TIMEOUT, + false, domain, IMCTR)) + dev_err_ratelimited(domain->mmu->dev, "TLB sync timed out -- MMU may be deadlocked\n"); - return; - } - udelay(1); - } } static void ipmmu_tlb_invalidate(struct ipmmu_vmsa_domain *domain) -- 2.34.1