From: Konrad Dybcio <konradybcio@kernel.org>
To: Sibi Sankar <quic_sibis@quicinc.com>,
sudeep.holla@arm.com, cristian.marussi@arm.com
Cc: linux-kernel@vger.kernel.org, arm-scmi@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-arm-msm@vger.kernel.org, johan@kernel.org,
konradybcio@kernel.org
Subject: Re: [PATCH V2 2/2] firmware: arm_scmi: Skip adding bad duplicates
Date: Wed, 4 Sep 2024 15:56:59 +0200 [thread overview]
Message-ID: <84adb06f-20f0-4e3d-9a6e-43e4b0d1b5ab@kernel.org> (raw)
In-Reply-To: <20240904031324.2901114-3-quic_sibis@quicinc.com>
On 4.09.2024 5:13 AM, Sibi Sankar wrote:
> Ensure that the bad duplicates reported by the platform firmware doesn't
> get added to the opp-tables.
>
> Signed-off-by: Sibi Sankar <quic_sibis@quicinc.com>
> ---
> drivers/firmware/arm_scmi/perf.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c
> index 2d77b5f40ca7..114c3dd70ede 100644
> --- a/drivers/firmware/arm_scmi/perf.c
> +++ b/drivers/firmware/arm_scmi/perf.c
> @@ -386,9 +386,11 @@ process_response_opp(struct device *dev, struct perf_dom_info *dom,
> le16_to_cpu(r->opp[loop_idx].transition_latency_us);
>
> ret = xa_insert(&dom->opps_by_lvl, opp->perf, opp, GFP_KERNEL);
> - if (ret)
> + if (ret) {
> dev_warn(dev, "Failed to add opps_by_lvl at %d for %s - ret:%d\n",
> opp->perf, dom->info.name, ret);
> + opp->perf = 0;
> + }
> }
>
> static inline void
> @@ -404,9 +406,12 @@ process_response_opp_v4(struct device *dev, struct perf_dom_info *dom,
> le16_to_cpu(r->opp[loop_idx].transition_latency_us);
>
> ret = xa_insert(&dom->opps_by_lvl, opp->perf, opp, GFP_KERNEL);
> - if (ret)
> + if (ret) {
> dev_warn(dev, "Failed to add opps_by_lvl at %d for %s - ret:%d\n",
> opp->perf, dom->info.name, ret);
> + opp->perf = 0;
> + return;
> + }
>
> /* Note that PERF v4 reports always five 32-bit words */
> opp->indicative_freq = le32_to_cpu(r->opp[loop_idx].indicative_freq);
> @@ -871,6 +876,10 @@ static int scmi_dvfs_device_opps_add(const struct scmi_protocol_handle *ph,
> else
> freq = dom->opp[idx].indicative_freq * dom->mult_factor;
>
> + /* Skip all invalid frequencies reported by the firmware */
> + if (!freq)
> + continue;
Maybe something like this instead? (not tested)
diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c
index 2d77b5f40ca7..530692119c79 100644
--- a/drivers/firmware/arm_scmi/perf.c
+++ b/drivers/firmware/arm_scmi/perf.c
@@ -431,8 +431,14 @@ iter_perf_levels_process_response(const struct scmi_protocol_handle *ph,
{
struct scmi_opp *opp;
struct scmi_perf_ipriv *p = priv;
+ unsigned int idx = st->desc_index + st->loop_idx;
+
+ opp = &p->perf_dom->opp[idx];
+
+ /* Avoid duplicate entries coming from buggy firmware */
+ if (idx > 0 && opp->perf && p->perf_dom->opp[idx - 1].perf)
+ return 0;
- opp = &p->perf_dom->opp[st->desc_index + st->loop_idx];
if (PROTOCOL_REV_MAJOR(p->version) <= 0x3)
process_response_opp(ph->dev, p->perf_dom, opp, st->loop_idx,
response);
Konrad
next prev parent reply other threads:[~2024-09-04 13:58 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-04 3:13 [PATCH V2 0/2] firmware: arm_scmi: Misc Fixes Sibi Sankar
2024-09-04 3:13 ` [PATCH V2 1/2] firmware: arm_scmi: Ensure that the message-id supports fastchannel Sibi Sankar
2024-09-04 7:00 ` Johan Hovold
2024-09-04 11:29 ` Konrad Dybcio
2024-09-04 12:38 ` Sudeep Holla
2024-09-04 14:20 ` Cristian Marussi
2024-09-05 12:54 ` Konrad Dybcio
2024-10-07 6:46 ` Sibi Sankar
2024-09-04 3:13 ` [PATCH V2 2/2] firmware: arm_scmi: Skip adding bad duplicates Sibi Sankar
2024-09-04 7:09 ` Johan Hovold
2024-09-04 8:05 ` Johan Hovold
2024-09-04 13:56 ` Konrad Dybcio [this message]
2024-09-04 14:00 ` Konrad Dybcio
2024-09-04 15:21 ` Cristian Marussi
2024-09-04 15:30 ` Cristian Marussi
2024-09-04 15:46 ` Cristian Marussi
2024-09-05 12:43 ` Cristian Marussi
2024-10-07 7:00 ` Sibi Sankar
2024-10-09 14:20 ` Cristian Marussi
2024-09-04 16:12 ` Sudeep Holla
2024-09-04 16:20 ` Cristian Marussi
2024-10-07 6:51 ` Sibi Sankar
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=84adb06f-20f0-4e3d-9a6e-43e4b0d1b5ab@kernel.org \
--to=konradybcio@kernel.org \
--cc=arm-scmi@vger.kernel.org \
--cc=cristian.marussi@arm.com \
--cc=johan@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_sibis@quicinc.com \
--cc=sudeep.holla@arm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).