clocksource: riscv: Patch riscv_clock_next_event() jump before first use
Subsystems (2)
PATCH 1/1 clocksource: riscv: Patch riscv_clock_next_event() jump before first use
A static key is used to select between SBI and Sstc timer usage in riscv_clock_next_event(), but currently the direction is resolved after cpuhp_setup_state() is called (which sets the next event). The first event will therefore fall through the sbi_set_timer() path; this breaks Sstc-only systems. So, apply the jump patching before first use.
--- drivers/clocksource/timer-riscv.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/clocksource/timer-riscv.c +5 -5
@@ -177,6 +177,11 @@ static int __init riscv_timer_init_dt(struct device_node *n)return error; } +if (riscv_isa_extension_available (NULL ,SSTC )) { +pr_info ("Timer interrupt in S-mode is available via sstc extension\n" ); +static_branch_enable (&riscv_sstc_available); + } + error =cpuhp_setup_state (CPUHP_AP_RISCV_TIMER_STARTING ,"clockevents/riscv/timer:starting" , riscv_timer_starting_cpu, riscv_timer_dying_cpu);
@@ -184,11 +189,6 @@ static int __init riscv_timer_init_dt(struct device_node *n)pr_err ("cpu hp setup state failed for RISCV timer [%d]\n" , error); -if (riscv_isa_extension_available (NULL ,SSTC )) { -pr_info ("Timer interrupt in S-mode is available via sstc extension\n" ); -static_branch_enable (&riscv_sstc_available); - } -return error; }
Signature · 8 lines
2.30.2 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Hey Matt,
Quoted 8 lines · Matt Evans
A static key is used to select between SBI and Sstc timer usage in
riscv_clock_next_event(), but currently the direction is resolved aftercpuhp_setup_state()is called (which sets the next event). The first event will therefore fall through thesbi_set_timer()path; this breaks Sstc-only systems. So, apply the jump patching before first use.Signed-off-by Matt Evans <[email protected]>
Your logic in this patch looks grand, just got two process bits for ya. Firstly, you're missing a fixes tag, which I would imagine is:
Also, of late, the clocksource maintainers, who you have not CCed, have been the ones that pick up patches that only touch this driver. Might be worth a resubmission CCing them...
Cheers,
Conor.
Quoted 41 lines
--- drivers/clocksource/timer-riscv.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/clocksource/timer-riscv.c +5
-5@@ -177,6 +177,11 @@ static int __init riscv_timer_init_dt(struct device_node *n)return error; } +if (riscv_isa_extension_available (NULL ,SSTC )) { +pr_info ("Timer interrupt in S-mode is available via sstc extension\n" ); +static_branch_enable (&riscv_sstc_available); + } + error =cpuhp_setup_state (CPUHP_AP_RISCV_TIMER_STARTING ,"clockevents/riscv/timer:starting" , riscv_timer_starting_cpu, riscv_timer_dying_cpu);@@ -184,11 +189,6 @@ static int __init riscv_timer_init_dt(struct device_node *n)pr_err ("cpu hp setup state failed for RISCV timer [%d]\n" , error); -if (riscv_isa_extension_available (NULL ,SSTC )) { -pr_info ("Timer interrupt in S-mode is available via sstc extension\n" ); -static_branch_enable (&riscv_sstc_available); - } -return error; }Signature · 8 lines
2.30.2 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Hi Conor,
Quoted 14 lines · Conor Dooley
Hey Matt,
Quoted 8 lines · Matt Evans
A static key is used to select between SBI and Sstc timer usage in
riscv_clock_next_event(), but currently the direction is resolved aftercpuhp_setup_state()is called (which sets the next event). The first event will therefore fall through thesbi_set_timer()path; this breaks Sstc-only systems. So, apply the jump patching before first use.Signed-off-by Matt Evans <[email protected]>
Quoted 7 lines
Your logic in this patch looks grand, just got two process bits for ya. Firstly, you're missing a fixes tag, which I would imagine is:
Fixes 9f7a8ff6391f ("RISC-V: Prefer sstc extension if available")Also, of late, the clocksource maintainers, who you have not CCed, have been the ones that pick up patches that only touch this driver. Might be worth a resubmission CCing them...
Both good points, many thanks. True, it fixes(:) 9f7a8ff6391f, and TIL on the shepherd chain. I’ll re-send.
Cheers,
Matt
Quoted 41 lines
Cheers,
Conor.Quoted 37 lines
---
drivers/clocksource/timer-riscv.c| 10 +++++-----1 file changed, 5 insertions(+), 5 deletions(-)drivers/clocksource/timer-riscv.c +5
-5@@ -177,6 +177,11 @@ static int __init riscv_timer_init_dt(struct device_node *n)return error; } +if (riscv_isa_extension_available (NULL ,SSTC )) { +pr_info ("Timer interrupt in S-mode is available via sstc extension\n" ); +static_branch_enable (&riscv_sstc_available); + } + error =cpuhp_setup_state (CPUHP_AP_RISCV_TIMER_STARTING ,"clockevents/riscv/timer:starting" , riscv_timer_starting_cpu, riscv_timer_dying_cpu);@@ -184,11 +189,6 @@ static int __init riscv_timer_init_dt(struct device_node *n)pr_err ("cpu hp setup state failed for RISCV timer [%d]\n" , error); -if (riscv_isa_extension_available (NULL ,SSTC )) { -pr_info ("Timer interrupt in S-mode is available via sstc extension\n" ); -static_branch_enable (&riscv_sstc_available); - } -return error; }Signature · 1 line
2.30.2
Quoted 4 lines
Quoted 4 lines
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv