firmware: arm_scmi: Miscellaneous improvements
cover firmware: arm_scmi: Miscellaneous improvements
Hi all,
This patch series contains miscellaneous improvements for SCMI quirk handling and SCMI instance iteration.
Thanks for your comments!
Geert Uytterhoeven (3):
firmware: arm_scmi: quirk: Improve quirk range parsing
firmware: arm_scmi: quirk: Simplify quirk table iteration
firmware: arm_scmi: Convert to list_for_each_entry()
drivers/firmware/arm_scmi/driver.c | 4 +--- drivers/firmware/arm_scmi/quirks.c | 15 ++++++--------- 2 files changed, 7 insertions(+), 12 deletions(-)
Signature · 12 lines
2.43.0
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus TorvaldsPATCH 1/3 firmware: arm_scmi: quirk: Improve quirk range parsing
When a range contains only an end ("-X"), the number string is parsed twice, as both "sep == first" and "sep != last" are true. Fix this by dropping the superfluous number parsing for "sep == first".
This does have a harmless functional impact for the unbounded range:
"-" is now accepted, while it was rejected before.
--- drivers/firmware/arm_scmi/quirks.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/firmware/arm_scmi/quirks.c +5 -6
@@ -238,16 +238,15 @@ static int scmi_quirk_range_parse(struct scmi_quirk *quirk)if (sep) *sep ='\0' ; -if (sep == first)/* -X */ - ret =kstrtouint (first +1 ,0 , &quirk->end_range); -else /* X OR X- OR X-y */ +if (sep != first)/* X OR X- OR X-y */ { ret =kstrtouint (first,0 , &quirk->start_range); -if (ret) -return ret; +if (ret) +return ret; + }if (!sep) quirk->end_range = quirk->start_range; -else if (sep != last)/* x-Y */ +else if (sep != last)/* -X OR x-Y */ ret =kstrtouint (sep +1 ,0 , &quirk->end_range);if (quirk->start_range > quirk->end_range)
Signature · 1 line
2.43.0
Sudeep Holla
maintainerRe: [PATCH 1/3] firmware: arm_scmi: quirk: Improve quirk range parsing
Quoted 7 lines · Geert Uytterhoeven
When a range contains only an end ("-X"), the number string is parsed twice, as both "sep == first" and "sep != last" are true. Fix this by dropping the superfluous number parsing for "sep == first".
This does have a harmless functional impact for the unbounded range:
"-" is now accepted, while it was rejected before.
Supporting "-" is good but I think the ret is uninitialised in that case as sep, first and last are all equal. If you agree, I can patch up by initialising ret to 0. Let me know if I am missing any other case where it is not good to have ret initialised to 0.
Signature · 2 lines
Regards, Sudeep
Re: [PATCH 1/3] firmware: arm_scmi: quirk: Improve quirk range parsing
Hi Sudeep,
Quoted 5 lines · Sudeep Holla
Quoted 4 lines · Geert Uytterhoeven
When a range contains only an end ("-X"), the number string is parsed twice, as both "sep == first" and "sep != last" are true. Fix this by dropping the superfluous number parsing for "sep == first".
Quoted 7 lines
Quoted 2 lines
This does have a harmless functional impact for the unbounded range:
"-" is now accepted, while it was rejected before.Supporting "-" is good but I think the ret is uninitialised in that case as sep, first and last are all equal. If you agree, I can patch up by initialising ret to 0. Let me know if I am missing any other case where it is not good to have ret initialised to 0.
My bad, ret should indeed be preinitialized to zero. Thanks for fixing!
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Sudeep Holla
maintainerRe: [PATCH 1/3] firmware: arm_scmi: quirk: Improve quirk range parsing
Quoted 11 lines · Geert Uytterhoeven
Hi Sudeep,
Quoted 8 lines · Sudeep Holla
Quoted 6 lines · Geert Uytterhoeven
When a range contains only an end ("-X"), the number string is parsed twice, as both "sep == first" and "sep != last" are true. Fix this by dropping the superfluous number parsing for "sep == first".
This does have a harmless functional impact for the unbounded range:
"-" is now accepted, while it was rejected before.
Quoted 6 lines
Quoted 4 lines
Supporting "-" is good but I think the ret is uninitialised in that case as sep, first and last are all equal. If you agree, I can patch up by initialising ret to 0. Let me know if I am missing any other case where it is not good to have ret initialised to 0.
My bad, ret should indeed be preinitialized to zero.
Thanks for confirming.
Quoted 2 lines
Thanks for fixing!
Pushed now, will let the build/other bots take a spin and then I will announce as applied if there are no other issues(which should be the case as it has been in my -next for a while)
Signature · 2 lines
Regards, Sudeep
PATCH 2/3 firmware: arm_scmi: quirk: Simplify quirk table iteration
In reply to Geert UytterhoevenThe current table entry is assigned in both the init and loop expressions of the for-statement. Merge this into a single assignment in the conditional expression, to simplify the code.
While at it, make the loop counter unsigned and loop-local.
--- drivers/firmware/arm_scmi/quirks.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/firmware/arm_scmi/quirks.c +1 -3
@@ -258,10 +258,8 @@ static int scmi_quirk_range_parse(struct scmi_quirk *quirk)void scmi_quirks_initialize (void ) {struct scmi_quirk *quirk; -int i; -for (i =0 , quirk = scmi_quirks_table[0 ]; quirk; - i++, quirk = scmi_quirks_table[i]) { +for (unsigned int i =0 ; (quirk = scmi_quirks_table[i]); i++) {int ret; ret =scmi_quirk_range_parse (quirk);
Signature · 1 line
2.43.0
PATCH 3/3 firmware: arm_scmi: Convert to list_for_each_entry()
In reply to Geert UytterhoevenSimplify the loop in scmi_handle_get() by using list_for_each_entry().
--- drivers/firmware/arm_scmi/driver.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/firmware/arm_scmi/driver.c +1 -3
@@ -2584,13 +2584,11 @@ static bool scmi_is_transport_atomic(const struct scmi_handle *handle,*/ static struct scmi_handle *scmi_handle_get (struct device *dev) { -struct list_head *p;struct scmi_info *info;struct scmi_handle *handle =NULL ;mutex_lock (&scmi_list_mutex); -list_for_each (p, &scmi_list) { - info = list_entry(p, struct scmi_info, node); +list_for_each_entry (info, &scmi_list, node) {if (dev->parent == info->dev) { info->users++; handle = &info->handle;
Signature · 1 line
2.43.0
Cristian Marussi
reviewerQuoted 1 line · Geert Uytterhoeven
Hi all,
Hi Geert,
thanks for this, first of all.
I was a bit off the keyboard so the delay in my answer.
I will get back at this SCMI/Clocks/Quirks matters in the next few weeks targeting next rc1-ish...
In a nutshell I was thinking to proceed roughly as follows:
- respinning a V3 of my original Clock Rates series WITH the addtion of your previous fixes series on top (or merged into) BUT DROPPING from my original series the patch that triggered a lot of FW panics in the wild due to out of spec FWs. (Harden Clock protocol initialization)
- spinning another NEW series on top of this 'Miscellaneous improvement' series of yours, since I want to add, on top of this rework of yours, the capability for the Quirk framework to match the same quirk definition (static key) against multiple vendors/subvendors/impl....since, as you may have noticed :P, I broke a number of boards recently with just one fix kernel side BUT all of these issues can be really quirked using some common identical quirk snippet to match against all the needed vendors (rockchip/nxp/renesas as of now)
...I have some ugly working hack with which I am experimenting on this quirk matching evolution...
On top of all of this I would then reapply the FW-breaking fix AND all the quirks we determine as needed (possibly N matching M vendoes) and test as much as possible pushing into for-next...
Then we'll see what Sudeep thinks about all of this, of course.
Thoughts ? Any feedback welcome.
Thanks,
Cristian
Quoted 8 lines · Geert Uytterhoeven
Hi all,
This patch series contains miscellaneous improvements for SCMI quirk handling and SCMI instance iteration.
Thanks for your comments!
[...]
Applied to sudeep.holla/linux (for-next/scmi/updates), thanks!
[1/3] firmware: arm_scmi: quirk: Improve quirk range parsing
https://git.kernel.org/sudeep.holla/c/6991e5de9709 [2/3] firmware: arm_scmi: quirk: Simplify quirk table iteration https://git.kernel.org/sudeep.holla/c/5be6732f820c [3/3] firmware: arm_scmi: Convert to list_for_each_entry() https://git.kernel.org/sudeep.holla/c/145728fb616a
--
Regards,
Sudeep