Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3563931pxb; Mon, 24 Jan 2022 12:18:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJz851WVNMYmckUH3yu9PfSS8PZ9V2ZRPXCUkzL+tQzvI/F+N/qKTlGKasumdJzz/9Id+fhN X-Received: by 2002:a17:90b:2385:: with SMTP id mr5mr2363pjb.186.1643055526184; Mon, 24 Jan 2022 12:18:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643055526; cv=none; d=google.com; s=arc-20160816; b=m6uuJsp5c93eYuvxdJGqernCBvBay6Qk5RbqYoUn0IJ+ihLcRv5XB6KXVOdTde343k kiEJXKxYMYp4luChmnpCeV/QlToWOri5qeGmnW6vxvjHqGrECU5DVE+ek/e60w/jBZQo 46po6YiFkz11qsmxjrD6A2Pj2m+1/0YgmXkGN1y053JeHgVbx0TgJ46tM/rtjFXibcu3 0IlyRuK4m+gZGZymPJO0YNLZofxjXACr8A1SX5NMCDQfNpGEV77t/GG+SJiAlTIkZBuQ 4jbX5szjU1n0cMihdelXTSU587FEbBWPN9mrBwGHnY7z7XaY1GwJmDNrnCLV0Yz6ZGOt 49zw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=U45ctoWWimdo/ftSwS81U6MaxeB+hjz4azyvyHOm7a4=; b=cPdaSDNYnI3bu5RNcbNEz5DZE8bsSGcjzR2b4MCPvrq/BtT35wbFV9rxP/dMPvlBAY s6YJj3gKmqA4PYChFlB3GyL5p5a3yV3UMNFfMzRJyTSpxaNCp3j0yHMLWt3RzKIT+uJo cXpVD4kK3ftihdaXbkmL6BjqPrwdR8dfavq6sWYbjj+FSnaKpJXAIusnbsLfluqCr4nC VfoZOFM2reXFNYg5Rr+EciKdO/rX1WfmxNfBpz3Zy42FNgqmh3KSINYbE1hlH7RbrVav tVPioRIergJmOq0R+gFr1ghW3oGHwKcAyvJ1jpqu589GpAxApuIl2BjnnaLpamZP5DAF /YNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Svz7jkVx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s9si12783786plq.229.2022.01.24.12.18.32; Mon, 24 Jan 2022 12:18:46 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Svz7jkVx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344402AbiAXTX6 (ORCPT + 99 others); Mon, 24 Jan 2022 14:23:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348178AbiAXTO7 (ORCPT ); Mon, 24 Jan 2022 14:14:59 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9953C0612F9; Mon, 24 Jan 2022 11:06:13 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8E7A6B8122C; Mon, 24 Jan 2022 19:06:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3E0BC340E5; Mon, 24 Jan 2022 19:06:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051172; bh=B7mjUnZq8ZfyVsarG1B9zQS0XV+aXbFi/U1xJGdxK64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Svz7jkVxxJcDukhQGB5M0fZCNdEDnL3cbhkv+D4WrRPll872hGDL4oSTGOjAsT5d5 UJixNK8oqjYSlMfBMIWcrx6nVJUOHCRn/3N/fhP894YjuRVnMyacB+C16UBOOXjI9Y glQXSc9hd+WbxG/qU+F++M2Z7DiB6k9qHn+6KmEo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxime Ripard , Stephen Boyd , Nicolas Saenz Julienne , Michael Stapelberg , Sasha Levin Subject: [PATCH 4.14 035/186] clk: bcm-2835: Remove rounding up the dividers Date: Mon, 24 Jan 2022 19:41:50 +0100 Message-Id: <20220124183938.253195344@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183937.101330125@linuxfoundation.org> References: <20220124183937.101330125@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maxime Ripard [ Upstream commit 8ca011ef4af48a7af7b15afd8a4a44039dd04cea ] The driver, once it found a divider, tries to round it up by increasing the least significant bit of the fractional part by one when the round_up argument is set and there's a remainder. However, since it increases the divider it will actually reduce the clock rate below what we were asking for, leading to issues with clk_set_min_rate() that will complain that our rounded clock rate is below the minimum of the rate. Since the dividers are fairly precise already, let's remove that part so that we can have clk_set_min_rate() working. This is effectively a revert of 9c95b32ca093 ("clk: bcm2835: add a round up ability to the clock divisor"). Fixes: 9c95b32ca093 ("clk: bcm2835: add a round up ability to the clock divisor") Signed-off-by: Maxime Ripard Acked-by: Stephen Boyd Reviewed-by: Nicolas Saenz Julienne Tested-by: Nicolas Saenz Julienne # boot and basic functionality Tested-by: Michael Stapelberg Link: https://patchwork.freedesktop.org/patch/msgid/20210922125419.4125779-3-maxime@cerno.tech Signed-off-by: Sasha Levin --- drivers/clk/bcm/clk-bcm2835.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c index d6cd1cc3f8e4d..8ccd72cc66bab 100644 --- a/drivers/clk/bcm/clk-bcm2835.c +++ b/drivers/clk/bcm/clk-bcm2835.c @@ -949,8 +949,7 @@ static int bcm2835_clock_is_on(struct clk_hw *hw) static u32 bcm2835_clock_choose_div(struct clk_hw *hw, unsigned long rate, - unsigned long parent_rate, - bool round_up) + unsigned long parent_rate) { struct bcm2835_clock *clock = bcm2835_clock_from_hw(hw); const struct bcm2835_clock_data *data = clock->data; @@ -962,10 +961,6 @@ static u32 bcm2835_clock_choose_div(struct clk_hw *hw, rem = do_div(temp, rate); div = temp; - - /* Round up and mask off the unused bits */ - if (round_up && ((div & unused_frac_mask) != 0 || rem != 0)) - div += unused_frac_mask + 1; div &= ~unused_frac_mask; /* different clamping limits apply for a mash clock */ @@ -1096,7 +1091,7 @@ static int bcm2835_clock_set_rate(struct clk_hw *hw, struct bcm2835_clock *clock = bcm2835_clock_from_hw(hw); struct bcm2835_cprman *cprman = clock->cprman; const struct bcm2835_clock_data *data = clock->data; - u32 div = bcm2835_clock_choose_div(hw, rate, parent_rate, false); + u32 div = bcm2835_clock_choose_div(hw, rate, parent_rate); u32 ctl; spin_lock(&cprman->regs_lock); @@ -1147,7 +1142,7 @@ static unsigned long bcm2835_clock_choose_div_and_prate(struct clk_hw *hw, if (!(BIT(parent_idx) & data->set_rate_parent)) { *prate = clk_hw_get_rate(parent); - *div = bcm2835_clock_choose_div(hw, rate, *prate, true); + *div = bcm2835_clock_choose_div(hw, rate, *prate); *avgrate = bcm2835_clock_rate_from_divisor(clock, *prate, *div); -- 2.34.1