From: Jerome Brunet <jbrunet@baylibre.com>
To: Chuan Liu <chuan.liu@amlogic.com>
Cc: neil.armstrong@linaro.org,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
Kevin Hilman <khilman@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
Jian Hu <jian.hu@amlogic.com>,
Dmitry Rokosov <ddrokosov@sberdevices.ru>,
Yu Tu <yu.tu@amlogic.com>,
linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] clk: meson: Fix the determine rate error in clk_regmap_divider_ro_ops
Date: Wed, 13 Nov 2024 09:36:16 +0100 [thread overview]
Message-ID: <1j7c97v8cf.fsf@starbuckisacylon.baylibre.com> (raw)
In-Reply-To: <da391fec-738a-4044-a598-fee1137dfa5c@amlogic.com> (Chuan Liu's message of "Wed, 13 Nov 2024 14:55:50 +0800")
On Wed 13 Nov 2024 at 14:55, Chuan Liu <chuan.liu@amlogic.com> wrote:
file changed, 20 insertions(+), 16 deletions(-)
>>>
>>> diff --git a/drivers/clk/meson/clk-regmap.c
>>> b/drivers/clk/meson/clk-regmap.c
>>> index 07f7e441b916..edf65ca92c7a 100644
>>> --- a/drivers/clk/meson/clk-regmap.c
>>> +++ b/drivers/clk/meson/clk-regmap.c
>>> @@ -80,21 +80,6 @@ static int clk_regmap_div_determine_rate(struct
>>> clk_hw *hw,
>>> {
>>> struct clk_regmap *clk = to_clk_regmap(hw);
>>> struct clk_regmap_div_data *div = clk_get_regmap_div_data(clk);
>>> - unsigned int val;
>>> - int ret;
>>> -
>>> - /* if read only, just return current value */
>>> - if (div->flags & CLK_DIVIDER_READ_ONLY) {
>>
>> You're breaking current code by no more checking this flag,
>> the new clk_regmap_div_ro_determine_rate() is fine, but you should call
>> it from here if CLK_DIVIDER_READ_ONLY is set.
>
> My idea is that the newly added clk_regmap_div_ro_determine_rate()
Whatever your idea is, what has been submitted is broken, as Neil
pointed out
> implements the functionality of handling CLK_DIVIDER_READ_ONLY in
> clk_regmap_div_determine_rate(). If we still keep the logic for
> handling CLK_DIVIDER_READ_ONLY here, it will make
> clk_regmap_div_determine_rate() ambiguous and easily confused.
That would just shift the problem from one function to other.
Please apply Neil's suggestion.
>
>>
>> Neil
>>
>>> - ret = regmap_read(clk->map, div->offset, &val);
>>> - if (ret)
>>> - return ret;
>>> -
>>> - val >>= div->shift;
>>> - val &= clk_div_mask(div->width);
>>> -
>>> - return divider_ro_determine_rate(hw, req, div->table,
>>> - div->width, div->flags,
>>> val);
>>> - }
>>>
>>> return divider_determine_rate(hw, req, div->table, div->width,
>>> div->flags);
>>> @@ -127,9 +112,28 @@ const struct clk_ops clk_regmap_divider_ops = {
>>> };
>>> EXPORT_SYMBOL_NS_GPL(clk_regmap_divider_ops, CLK_MESON);
>>>
>>> +static int clk_regmap_div_ro_determine_rate(struct clk_hw *hw,
>>> + struct clk_rate_request *req)
>>> +{
>>> + struct clk_regmap *clk = to_clk_regmap(hw);
>>> + struct clk_regmap_div_data *div = clk_get_regmap_div_data(clk);
>>> + unsigned int val;
>>> + int ret;
>>> +
>>> + ret = regmap_read(clk->map, div->offset, &val);
>>> + if (ret)
>>> + return ret;
>>> +
>>> + val >>= div->shift;
>>> + val &= clk_div_mask(div->width);
>>> +
>>> + return divider_ro_determine_rate(hw, req, div->table, div->width,
>>> + div->flags, val);
>>> +}
>>> +
>>> const struct clk_ops clk_regmap_divider_ro_ops = {
>>> .recalc_rate = clk_regmap_div_recalc_rate,
>>> - .determine_rate = clk_regmap_div_determine_rate,
>>> + .determine_rate = clk_regmap_div_ro_determine_rate,
>>> };
>>> EXPORT_SYMBOL_NS_GPL(clk_regmap_divider_ro_ops, CLK_MESON);
>>>
>>>
>>> ---
>>> base-commit: 664988eb47dd2d6ae1d9e4188ec91832562f8f26
>>> change-id:
>>> 20241111-fix_childclk_of_roclk_has_been_tampered_with-61dbcc623746
>>>
>>> Best regards,
>>
--
Jerome
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
WARNING: multiple messages have this Message-ID (diff)
From: Jerome Brunet <jbrunet@baylibre.com>
To: Chuan Liu <chuan.liu@amlogic.com>
Cc: neil.armstrong@linaro.org,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
Kevin Hilman <khilman@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
Jian Hu <jian.hu@amlogic.com>,
Dmitry Rokosov <ddrokosov@sberdevices.ru>,
Yu Tu <yu.tu@amlogic.com>,
linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] clk: meson: Fix the determine rate error in clk_regmap_divider_ro_ops
Date: Wed, 13 Nov 2024 09:36:16 +0100 [thread overview]
Message-ID: <1j7c97v8cf.fsf@starbuckisacylon.baylibre.com> (raw)
In-Reply-To: <da391fec-738a-4044-a598-fee1137dfa5c@amlogic.com> (Chuan Liu's message of "Wed, 13 Nov 2024 14:55:50 +0800")
On Wed 13 Nov 2024 at 14:55, Chuan Liu <chuan.liu@amlogic.com> wrote:
file changed, 20 insertions(+), 16 deletions(-)
>>>
>>> diff --git a/drivers/clk/meson/clk-regmap.c
>>> b/drivers/clk/meson/clk-regmap.c
>>> index 07f7e441b916..edf65ca92c7a 100644
>>> --- a/drivers/clk/meson/clk-regmap.c
>>> +++ b/drivers/clk/meson/clk-regmap.c
>>> @@ -80,21 +80,6 @@ static int clk_regmap_div_determine_rate(struct
>>> clk_hw *hw,
>>> {
>>> struct clk_regmap *clk = to_clk_regmap(hw);
>>> struct clk_regmap_div_data *div = clk_get_regmap_div_data(clk);
>>> - unsigned int val;
>>> - int ret;
>>> -
>>> - /* if read only, just return current value */
>>> - if (div->flags & CLK_DIVIDER_READ_ONLY) {
>>
>> You're breaking current code by no more checking this flag,
>> the new clk_regmap_div_ro_determine_rate() is fine, but you should call
>> it from here if CLK_DIVIDER_READ_ONLY is set.
>
> My idea is that the newly added clk_regmap_div_ro_determine_rate()
Whatever your idea is, what has been submitted is broken, as Neil
pointed out
> implements the functionality of handling CLK_DIVIDER_READ_ONLY in
> clk_regmap_div_determine_rate(). If we still keep the logic for
> handling CLK_DIVIDER_READ_ONLY here, it will make
> clk_regmap_div_determine_rate() ambiguous and easily confused.
That would just shift the problem from one function to other.
Please apply Neil's suggestion.
>
>>
>> Neil
>>
>>> - ret = regmap_read(clk->map, div->offset, &val);
>>> - if (ret)
>>> - return ret;
>>> -
>>> - val >>= div->shift;
>>> - val &= clk_div_mask(div->width);
>>> -
>>> - return divider_ro_determine_rate(hw, req, div->table,
>>> - div->width, div->flags,
>>> val);
>>> - }
>>>
>>> return divider_determine_rate(hw, req, div->table, div->width,
>>> div->flags);
>>> @@ -127,9 +112,28 @@ const struct clk_ops clk_regmap_divider_ops = {
>>> };
>>> EXPORT_SYMBOL_NS_GPL(clk_regmap_divider_ops, CLK_MESON);
>>>
>>> +static int clk_regmap_div_ro_determine_rate(struct clk_hw *hw,
>>> + struct clk_rate_request *req)
>>> +{
>>> + struct clk_regmap *clk = to_clk_regmap(hw);
>>> + struct clk_regmap_div_data *div = clk_get_regmap_div_data(clk);
>>> + unsigned int val;
>>> + int ret;
>>> +
>>> + ret = regmap_read(clk->map, div->offset, &val);
>>> + if (ret)
>>> + return ret;
>>> +
>>> + val >>= div->shift;
>>> + val &= clk_div_mask(div->width);
>>> +
>>> + return divider_ro_determine_rate(hw, req, div->table, div->width,
>>> + div->flags, val);
>>> +}
>>> +
>>> const struct clk_ops clk_regmap_divider_ro_ops = {
>>> .recalc_rate = clk_regmap_div_recalc_rate,
>>> - .determine_rate = clk_regmap_div_determine_rate,
>>> + .determine_rate = clk_regmap_div_ro_determine_rate,
>>> };
>>> EXPORT_SYMBOL_NS_GPL(clk_regmap_divider_ro_ops, CLK_MESON);
>>>
>>>
>>> ---
>>> base-commit: 664988eb47dd2d6ae1d9e4188ec91832562f8f26
>>> change-id:
>>> 20241111-fix_childclk_of_roclk_has_been_tampered_with-61dbcc623746
>>>
>>> Best regards,
>>
--
Jerome
next prev parent reply other threads:[~2024-11-13 8:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-12 12:57 [PATCH v2] clk: meson: Fix the determine rate error in clk_regmap_divider_ro_ops Chuan Liu
2024-11-12 12:57 ` Chuan Liu via B4 Relay
2024-11-12 12:57 ` Chuan Liu via B4 Relay
2024-11-12 13:04 ` Chuan Liu
2024-11-12 13:04 ` Chuan Liu
2024-11-12 13:24 ` Neil Armstrong
2024-11-12 13:24 ` Neil Armstrong
2024-11-13 6:55 ` Chuan Liu
2024-11-13 6:55 ` Chuan Liu
2024-11-13 8:36 ` Jerome Brunet [this message]
2024-11-13 8:36 ` Jerome Brunet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1j7c97v8cf.fsf@starbuckisacylon.baylibre.com \
--to=jbrunet@baylibre.com \
--cc=chuan.liu@amlogic.com \
--cc=ddrokosov@sberdevices.ru \
--cc=jian.hu@amlogic.com \
--cc=khilman@baylibre.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=mturquette@baylibre.com \
--cc=neil.armstrong@linaro.org \
--cc=sboyd@kernel.org \
--cc=yu.tu@amlogic.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.