Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp990007pxb; Wed, 3 Mar 2021 23:43:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJx6YcTt5M7AzQ7FImq2qnrs2hQMVs1c9R5qeTY5LNG4zyxMn0/4oCFTQhgi0wPTzIRPUKQw X-Received: by 2002:a50:a402:: with SMTP id u2mr2879814edb.383.1614843797251; Wed, 03 Mar 2021 23:43:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614843797; cv=none; d=google.com; s=arc-20160816; b=CdS4SSqMZzNUAFhPPlUY9Mt920XurPXjwtwQB6iUnDkhSc5q3l5O/A73Rua/FfzeEo ME90YppO2trcg3DU6AiZBDFvzgbCO73DL7JIzHHnVC4fdQ0z0V/55U812A3znZEhB6b5 P56biD2+BF4QaHlWuWbof4dLotDWhmvR026GXsgURxv2bv2mjIHy3pi+5PsmyVyZ/BMJ lwAeRNFM9hAfym6d0bDsVw3rtEidNntj/w7FPEuhNMR7VR+6Zlf7jpXJCIABJGouxVcK wU7xD3bz/PsOeJTeSXYIXmsMcujWqdP8KasqLmYw+zZyZNN1jnnnKROzmVsiyM9hkAQ3 ZiPw== 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 :message-id:date:subject:cc:to:from; bh=MtpFiK1XzZgaoBDeUdX1vLm7dK9sUC2Bwwf6rrdLThQ=; b=QzQVZSZb/FTFjSSacHe9FWAXQvvy22UO6wCllcrNzYpgSHySg1EFr8e4hl8zB7Ofta TerHvyCoOZljrNKimxlqtgA15pFxZA/XmcJlGv6FeC3MjxMNW5NPYz0jlVPw5q7QXnZ6 QiYFGC5PgNx0mbjwxQIQ0yu/H0oAuaS0LgN5CehdONGMXWSZzobzwSr7APpyOTZUAW3O UPnvdVXykxdBmZUC1ai4RWFbDCY6lZbO3QrCj45mVsXiyfoU4rxItlVnG2KhcC/fhW3z nIeEuL++y5ZIQLvupkXEK0692knK+Ib8beS+xyscEjt3rGu3e3nWRhAiF2k2cniMWN0t jkGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r21si14767819edy.321.2021.03.03.23.42.54; Wed, 03 Mar 2021 23:43:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357336AbhCCKt0 (ORCPT + 99 others); Wed, 3 Mar 2021 05:49:26 -0500 Received: from m-r2.th.seeweb.it ([5.144.164.171]:53497 "EHLO m-r2.th.seeweb.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233586AbhCBXzB (ORCPT ); Tue, 2 Mar 2021 18:55:01 -0500 X-Greylist: delayed 474 seconds by postgrey-1.27 at vger.kernel.org; Tue, 02 Mar 2021 18:54:42 EST Received: from Marijn-Arch-PC.localdomain (94-209-165-62.cable.dynamic.v4.ziggo.nl [94.209.165.62]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by m-r2.th.seeweb.it (Postfix) with ESMTPSA id F157E3ED8B; Wed, 3 Mar 2021 00:42:36 +0100 (CET) From: Marijn Suijten To: phone-devel@vger.kernel.org Cc: ~postmarketos/upstreaming@lists.sr.ht, angelogioacchino.delregno@somainline.org, konrad.dybcio@somainline.org, martin.botka@somainline.org, Marijn Suijten , Andy Gross , Bjorn Andersson , Michael Turquette , Stephen Boyd , linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] clk: qcom: rcg2: Rectify clk_gfx3d rate rounding without mux division Date: Wed, 3 Mar 2021 00:41:06 +0100 Message-Id: <20210302234106.3418665-1-marijn.suijten@somainline.org> X-Mailer: git-send-email 2.30.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In case the mux is not divided parent_req was mistakenly not assigned to leading __clk_determine_rate to determine the best frequency setting for a requested rate of 0, resulting in the msm8996 platform not booting. Rectify this by refactoring the logic to unconditionally assign to parent_req.rate with the clock rate the caller is expecting. Fixes: 7cbb78a99db6 ("clk: qcom: rcg2: Stop hardcoding gfx3d pingpong parent numbers") Reported-by: Konrad Dybcio Tested-by: Konrad Dybcio Reviewed-By: AngeloGioacchino Del Regno Signed-off-by: Marijn Suijten --- drivers/clk/qcom/clk-rcg2.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c index 42f13a2d1cc1..05ff3b0d233e 100644 --- a/drivers/clk/qcom/clk-rcg2.c +++ b/drivers/clk/qcom/clk-rcg2.c @@ -730,7 +730,8 @@ static int clk_gfx3d_determine_rate(struct clk_hw *hw, struct clk_rate_request parent_req = { }; struct clk_rcg2_gfx3d *cgfx = to_clk_rcg2_gfx3d(hw); struct clk_hw *xo, *p0, *p1, *p2; - unsigned long request, p0_rate; + unsigned long p0_rate; + u8 mux_div = cgfx->div; int ret; p0 = cgfx->hws[0]; @@ -750,14 +751,15 @@ static int clk_gfx3d_determine_rate(struct clk_hw *hw, return 0; } - request = req->rate; - if (cgfx->div > 1) - parent_req.rate = request = request * cgfx->div; + if (mux_div == 0) + mux_div = 1; + + parent_req.rate = req->rate * mux_div; /* This has to be a fixed rate PLL */ p0_rate = clk_hw_get_rate(p0); - if (request == p0_rate) { + if (parent_req.rate == p0_rate) { req->rate = req->best_parent_rate = p0_rate; req->best_parent_hw = p0; return 0; @@ -765,7 +767,7 @@ static int clk_gfx3d_determine_rate(struct clk_hw *hw, if (req->best_parent_hw == p0) { /* Are we going back to a previously used rate? */ - if (clk_hw_get_rate(p2) == request) + if (clk_hw_get_rate(p2) == parent_req.rate) req->best_parent_hw = p2; else req->best_parent_hw = p1; @@ -780,8 +782,7 @@ static int clk_gfx3d_determine_rate(struct clk_hw *hw, return ret; req->rate = req->best_parent_rate = parent_req.rate; - if (cgfx->div > 1) - req->rate /= cgfx->div; + req->rate /= mux_div; return 0; } -- 2.30.1