Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1927946rwd; Fri, 2 Jun 2023 02:07:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7jAwHVBneWeoBNE9DlxxS40ZnNq90Eg12cV798TdIpNjt4LWkLcFIzVeg7obRhCjk7ApmE X-Received: by 2002:a81:914c:0:b0:569:4fcc:1784 with SMTP id i73-20020a81914c000000b005694fcc1784mr1209591ywg.51.1685696864618; Fri, 02 Jun 2023 02:07:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685696864; cv=none; d=google.com; s=arc-20160816; b=brbjxuMejAeK/lJIhtn0WUl3e94Ov8so6X2W7ztdqtU7qVyh5dgCgJ1RH8yvXFB/rl HSRgVut9EnTs1X+lTGKrVd8liVK4wnkGy7Dz6yMQKXxyPw4deJRcVDiGNm3NPZ4Va9OR hg291July4biWaMIMIM8I3/nglcZeFlD7qI287CuWJSMFCOw35QFuUEhdDw+5ZcwGQvT snfTCEeqSFaCMwKsjeG7CjG5+CE+7otRCUC9hUsXiyRvEiO+5PGdq9AzLNss+OWe4l1z I/+gZ2VSOuc/XT5U/D9wd6QA1tFEOcC01DFReI7XKUHRel7d8kQCLcW0kbBUC/4BGlML 1Icw== 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=lZYXvtaHrXVHAnEzOhJR1rFXHYdmga1FwMtY7H6htyk=; b=yRpwmCMl71RgnOpRSB2LXT5REIJAf5kXHzbNTPSSrnSJYKqRsQttDWH0LVA9Q5Xzki Zawofqdji/SBC0WdwTAIDEPzRSGAVodOkV1wY/SbfClA2IrpSz/QXWpZWRAeenvn7G3I FT2hmF4VmRUOaNgYxQF+2yA+K5FfmwrXHB9wjOP+FFo9Z54P4YZAvIMpcjccW0l2eXBD GNtMICmlyBRlhNfThMJ04IYpmB8VsbYoV8PheB4yt+jkDsvbAQC+f25i76HQr+XiWIpS sTwTCmrMlzlhv/RdyOt3nrev83cKx7TpOLlpksNJAaHWHBHbce8pUYFv0IeLIF9TMWKU R3XQ== 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 e29-20020aa7981d000000b0063b731e3938si463370pfl.2.2023.06.02.02.07.31; Fri, 02 Jun 2023 02:07:44 -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 S234986AbjFBIw3 (ORCPT + 99 others); Fri, 2 Jun 2023 04:52:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232404AbjFBIvy (ORCPT ); Fri, 2 Jun 2023 04:51:54 -0400 Received: from andre.telenet-ops.be (andre.telenet-ops.be [IPv6:2a02:1800:120:4::f00:15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DEBC1729 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 andre.telenet-ops.be with bizsmtp id 48qo2A00F1tRZS8018qoWX; 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-00BhYI-U1; Fri, 02 Jun 2023 10:50:48 +0200 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1q50Ui-00APxd-1F; 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 4/7] clk: renesas: mstp: Convert to readl_poll_timeout_atomic() Date: Fri, 2 Jun 2023 10:50:39 +0200 Message-Id: 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 R-Mobile APE6 and A1, R-Car H1, and SH-Mobile AG5. v3: - New. --- drivers/clk/renesas/clk-mstp.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/clk/renesas/clk-mstp.c b/drivers/clk/renesas/clk-mstp.c index 6e3c4a9c16b07ae9..e96457371b4cce88 100644 --- a/drivers/clk/renesas/clk-mstp.c +++ b/drivers/clk/renesas/clk-mstp.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -78,8 +79,8 @@ static int cpg_mstp_clock_endisable(struct clk_hw *hw, bool enable) struct mstp_clock_group *group = clock->group; u32 bitmask = BIT(clock->bit_index); unsigned long flags; - unsigned int i; u32 value; + int ret; spin_lock_irqsave(&group->lock, flags); @@ -102,19 +103,14 @@ static int cpg_mstp_clock_endisable(struct clk_hw *hw, bool enable) if (!enable || !group->mstpsr) return 0; - for (i = 1000; i > 0; --i) { - if (!(cpg_mstp_read(group, group->mstpsr) & bitmask)) - break; - cpu_relax(); - } - - if (!i) { + /* group->width_8bit is always false if group->mstpsr is present */ + ret = readl_poll_timeout_atomic(group->mstpsr, value, + !(value & bitmask), 0, 10); + if (ret) pr_err("%s: failed to enable %p[%d]\n", __func__, group->smstpcr, clock->bit_index); - return -ETIMEDOUT; - } - return 0; + return ret; } static int cpg_mstp_clock_enable(struct clk_hw *hw) -- 2.34.1