Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1926845rwd; Fri, 2 Jun 2023 02:06:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6cjJN8m6RkcJ3b9+An+/oYmtW4yRBeYnfRy3PS8VWZcK2jm/ECrSIfdTDPYQ4XS2XTYDiO X-Received: by 2002:a9d:7d99:0:b0:6af:7e2c:f155 with SMTP id j25-20020a9d7d99000000b006af7e2cf155mr1971811otn.29.1685696799967; Fri, 02 Jun 2023 02:06:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685696799; cv=none; d=google.com; s=arc-20160816; b=m6DE/Hkr9/Sipr3uHy7fC5WjovmU9sw/mKrXxL62R2drx35OKjvqtuBqyfqe2udK8w J7grLl1+ky5SKuDg+w2g2kTE0//acnxKFrVWTRg3OdNKsbZXZKWokivPm64XXRJaO8iU pQ3EcS6+MMy32cWYfbkkyiEK84J5o1Yp/qvAG0vslSn9vTSDL/3lt9lhtsTdCEBVytXV HBF7PiVOJOeJ0KI9Zb40YgLorTaJLPdBZz9nbGrw9kND1bw13AIagKOukWOffmO1eG1S qwNeouK8N2mAD3v8x4bEiFbOfkAWMPJYXRL+UszRdbCIQ2hpT3fyVDEYKT0mDCnc3oLq 6Ixg== 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=S84n690ubVJsfenBI9Ro1GEGFtsVaWu5UrTAnwgCPzc=; b=ZvPKLL0TCjDaCjHssr2iuXg1Y6Kw9Fr0MBrQHvV/We0L/eZiN5cHtgEB+59zbvrrlt N6mPpTwO2hnBn+77dz5BSSNADSfQAT4JWQ2aWY9JwLc66/ItHLHG6ftGMjiCuqIv/xhe El36kgBWqi3S53FKMvA9aVHniSzyLUbpCOou3QF0ZdiKNpi9uzxrcGXUPRCSGFStwB06 i+C5dldNQFvuZcUT6m80cP24qUAl9KsiXX5xwl7SaHucbUYTHdNDcxG1ddJyXHKwBvR6 cg7OWX4Faefkg6Alqb9wFXFPBmjk2Ut+fvbnHMwp06yTKYmMMiCJOUz/9051XpoIy35c sX8w== 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 z4-20020aa79904000000b0064e1b65f01dsi405118pff.237.2023.06.02.02.06.28; Fri, 02 Jun 2023 02:06:39 -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 S234501AbjFBIwk (ORCPT + 99 others); Fri, 2 Jun 2023 04:52:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234904AbjFBIv6 (ORCPT ); Fri, 2 Jun 2023 04:51:58 -0400 Received: from michel.telenet-ops.be (michel.telenet-ops.be [IPv6:2a02:1800:110:4::f00:18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2F2F1730 for ; Fri, 2 Jun 2023 01:51:15 -0700 (PDT) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed30:158c:2ccf:1f70:e136]) by michel.telenet-ops.be with bizsmtp id 48qo2A00B1tRZS8068qoZc; Fri, 02 Jun 2023 10:51:13 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1q50UO-00BhYO-Uv; Fri, 02 Jun 2023 10:50:48 +0200 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1q50Ui-00APxh-20; 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 5/7] clk: renesas: rzg2l: Convert to readl_poll_timeout_atomic() Date: Fri, 2 Jun 2023 10:50:40 +0200 Message-Id: <900543d4b9abc1004e6aecdb676f23e5508ae96f.1685692810.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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=unavailable 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 readl_poll_timeout_atomic() instead of open-coding the same operation. As typically no retries are needed, 10 µs is a suitable timeout value. Signed-off-by: Geert Uytterhoeven --- Polling measurements done on RZ/Five. v3: - New. --- drivers/clk/renesas/rzg2l-cpg.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/clk/renesas/rzg2l-cpg.c b/drivers/clk/renesas/rzg2l-cpg.c index ca8b921c77625317..bc623515ad843cf5 100644 --- a/drivers/clk/renesas/rzg2l-cpg.c +++ b/drivers/clk/renesas/rzg2l-cpg.c @@ -903,9 +903,9 @@ static int rzg2l_mod_clock_endisable(struct clk_hw *hw, bool enable) unsigned int reg = clock->off; struct device *dev = priv->dev; unsigned long flags; - unsigned int i; u32 bitmask = BIT(clock->bit); u32 value; + int error; if (!clock->off) { dev_dbg(dev, "%pC does not support ON/OFF\n", hw->clk); @@ -930,19 +930,13 @@ static int rzg2l_mod_clock_endisable(struct clk_hw *hw, bool enable) if (!priv->info->has_clk_mon_regs) return 0; - for (i = 1000; i > 0; --i) { - if (((readl(priv->base + CLK_MON_R(reg))) & bitmask)) - break; - cpu_relax(); - } - - if (!i) { + error = readl_poll_timeout_atomic(priv->base + CLK_MON_R(reg), value, + value & bitmask, 0, 10); + if (error) dev_err(dev, "Failed to enable CLK_ON %p\n", priv->base + CLK_ON_R(reg)); - return -ETIMEDOUT; - } - return 0; + return error; } static int rzg2l_mod_clock_enable(struct clk_hw *hw) -- 2.34.1