From patchwork Tue Jan 17 13:54:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 44679 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1767925wrn; Tue, 17 Jan 2023 05:57:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXuvWDIX2sh6mHBdfaT+LuyR4FkvERAVrbFIiXhK+blbFXDHLIwqMIcRJDA/7f1FDtNbYOan X-Received: by 2002:a17:906:6846:b0:84d:2fdf:a41b with SMTP id a6-20020a170906684600b0084d2fdfa41bmr2620023ejs.50.1673963872855; Tue, 17 Jan 2023 05:57:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673963872; cv=none; d=google.com; s=arc-20160816; b=r8pUKHGqTuj5UUl7GOBa1l2HAV2r5QeGHTXMRWn/PHPMzGngkvUNCUG+uwk41TJo2w hA5Xb/iVzS4jTht4cRifJt4Kl9H6b3a6BNYuuvdabFAgR2m65k6m0PbjEO8TyHlieqg2 xdN9FYpi8Tci99D6LLIrVeT8rywjawTMH5QSVqDApe2T+NeSwEEyR8+CyJO+3HKKLbda NMphaZvgrjIFGPN7uOV0E5f+qxqHHm0Og95sV0z/imjSiFxJxaTATrWqRD9ow6gt5000 dn+GjfTrTRRSnKONFdC18xsjkhcmVi1RmueQIZA0FhIK7Wp4mGyi3hdQTZfLWV4SGaK0 pjLw== 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 :dkim-signature; bh=Fl9uAlkhTt9RYlBsdPZ+Iiwc7QljNWDz/51SBuY/ELg=; b=P74GWRyPDI8nccPhYnzo1ad2WbyS0fs79eTRV4o6vBuGy12cqK2ia9tbM670Gi8od/ C1xnwIoH9eI8LITY+0JH26VFD+3+xoIwHPz0+rahMCevMAW9xJ+EY2WF0qMFNuPxOpTA sW4l0eINt2oLBo/OC5220jdrZl9iyvielNmcWvbLRZcuVFJLl+G/ITpgcafShGu0wg9v U3ekKu+X8OZcjLnfqYWlHnEVvLExUXu5ZLU5iENWm2K/w/XTvKrJf4nqCOfq7JV2FVEK Dp99Sdxz/Fcv0hEp/pcKnc4KhVaJk5WEgw3T4S3zdeIE+p8nQvg04F16Motg0dtdaQvd cwUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SHOi6CAI; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ww11-20020a170907084b00b007878c9d73a2si35906016ejb.426.2023.01.17.05.57.29; Tue, 17 Jan 2023 05:57:52 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SHOi6CAI; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231319AbjAQNzp (ORCPT + 99 others); Tue, 17 Jan 2023 08:55:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230299AbjAQNz0 (ORCPT ); Tue, 17 Jan 2023 08:55:26 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 812CC35B4; Tue, 17 Jan 2023 05:55:25 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id o17-20020a05600c511100b003db021ef437so3122962wms.4; Tue, 17 Jan 2023 05:55:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Fl9uAlkhTt9RYlBsdPZ+Iiwc7QljNWDz/51SBuY/ELg=; b=SHOi6CAIQZ7rSBG5BxuEzyBPFJstWdOK7h2G7Ar8FpFxLmE+y4RBFp4If/5kNcNC/U jW+hHR/cw8753ZF0q9sQ7kz5ebAmQkRUMmdzEa9hyA4LagyPc+FYJQzGCLAveabAd1EV 1XDl1dcIsY3Qou5QdHqpmCJLjXUeIHxPbuKG8LUyoOSFaxyPMK9SVIqoe8+76jk9LMhZ ErhcL7k/UKkWHR1nmqqeBQfkTAur2dd/8jN2jCgI2sHdzcgRfoADMm5MrXVpWKDnxKk2 R3BRhYfJAQ7N/N/5rVd0S63ckGH6HESJbJZT9MXVh7YFv98lnF6pH418eIWHDbiENQik 9t9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Fl9uAlkhTt9RYlBsdPZ+Iiwc7QljNWDz/51SBuY/ELg=; b=Xx76wQ751FzzCaTUUhvMyGl/P/bXjxvmJg+1EoxkoSOGQT44/nToTJgdFrBhtXUKMN YT5E/zp01HLbblexu7eWVhtA5SxcEBeYX3Jl2rjU2IRGvk+Ud7HyN47UNVgYhTuuL7WF J1KiEsiTnrXbgXYE/dNvGfQ/X8WogFeEn5aHeoeqXY/grKdTBE429PJ0b8k1N6jYyvo9 weyVvhsoYumXnHNtNEJyIthWHYzcSvOzW2qhbPo6CnANgpAgFfJ4uOu0JQlkulcnTbce OpZ26v5XAmNldfmdrPrykSKFHAs3c9y44IMJEqjdPzpUCWpPniS6gsQ0KIPj0ynMbJ8m sjNw== X-Gm-Message-State: AFqh2kqD5ljZx7xHKLQf4b4hz0wCjYz7Z4yv+FpRr3E6pH415xOY4eMr j3b+1Mn0ZPRyeRSR0qzCIMk= X-Received: by 2002:a05:600c:3c83:b0:3d9:e5d3:bf with SMTP id bg3-20020a05600c3c8300b003d9e5d300bfmr3110851wmb.32.1673963724002; Tue, 17 Jan 2023 05:55:24 -0800 (PST) Received: from localhost.localdomain (93-34-92-88.ip49.fastwebnet.it. [93.34.92.88]) by smtp.googlemail.com with ESMTPSA id s7-20020a1cf207000000b003d98438a43asm35147461wmc.34.2023.01.17.05.55.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 05:55:23 -0800 (PST) From: Christian Marangi To: Bjorn Andersson , Andy Gross , Konrad Dybcio , Michael Turquette , Stephen Boyd , linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christian Marangi Subject: [PATCH v3 4/6] clk: qcom: clk-rcg2: don't re-search config on rcg2_set_rate Date: Tue, 17 Jan 2023 14:54:57 +0100 Message-Id: <20230117135459.16868-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230117135459.16868-1-ansuelsmth@gmail.com> References: <20230117135459.16868-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755278342100833081?= X-GMAIL-MSGID: =?utf-8?q?1755278342100833081?= Currently the rcg2 driver search the rate to apply 2 times. - In _freq_tbl_determine_rate for the determine_rate function used by core clk to understand the best rate to set with set_rate - In rcg2_set_rate where the suggested rate is not trusted and searched another time using a CEIL or FLOOR policy. This is fundamentally wrong as we are ignoring what core clock is deciding and just setting whatever clock configuration we want for the suggested clock. The problem is in the fact that the correct clock should have already be searched and selected with the determine_rate function and set_rate should just apply whatever clock was provided. Rework the function using the find_req_exact and by trusting whatever core clk is asking to set. Signed-off-by: Christian Marangi --- drivers/clk/qcom/clk-rcg2.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c index 76551534f10d..3f15e993dc04 100644 --- a/drivers/clk/qcom/clk-rcg2.c +++ b/drivers/clk/qcom/clk-rcg2.c @@ -352,23 +352,12 @@ static int clk_rcg2_configure(struct clk_rcg2 *rcg, const struct freq_tbl *f) return update_config(rcg); } -static int __clk_rcg2_set_rate(struct clk_hw *hw, unsigned long rate, - enum freq_policy policy) +static int __clk_rcg2_set_rate(struct clk_hw *hw, unsigned long rate) { struct clk_rcg2 *rcg = to_clk_rcg2(hw); const struct freq_tbl *f; - switch (policy) { - case FLOOR: - f = qcom_find_freq_floor(rcg->freq_tbl, rate); - break; - case CEIL: - f = qcom_find_freq(rcg->freq_tbl, rate); - break; - default: - return -EINVAL; - } - + f = qcom_find_freq_exact(rcg->freq_tbl, rate); if (!f) return -EINVAL; @@ -378,25 +367,25 @@ static int __clk_rcg2_set_rate(struct clk_hw *hw, unsigned long rate, static int clk_rcg2_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate) { - return __clk_rcg2_set_rate(hw, rate, CEIL); + return __clk_rcg2_set_rate(hw, rate); } static int clk_rcg2_set_floor_rate(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate) { - return __clk_rcg2_set_rate(hw, rate, FLOOR); + return __clk_rcg2_set_rate(hw, rate); } static int clk_rcg2_set_rate_and_parent(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate, u8 index) { - return __clk_rcg2_set_rate(hw, rate, CEIL); + return __clk_rcg2_set_rate(hw, rate); } static int clk_rcg2_set_floor_rate_and_parent(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate, u8 index) { - return __clk_rcg2_set_rate(hw, rate, FLOOR); + return __clk_rcg2_set_rate(hw, rate); } static int clk_rcg2_get_duty_cycle(struct clk_hw *hw, struct clk_duty *duty)