Skip to content

Commit f467362

Browse files
Gavin Shanwilldeacon
authored andcommitted
firmware: arm_sdei: Introduce sdei_do_local_call()
During the CPU hotplug, the private events are registered, enabled or unregistered on the specific CPU. It repeats the same steps: initializing cross call argument, make function call on local CPU, check the returned error. This introduces sdei_do_local_call() to cover the first steps. The other benefit is to make CROSSCALL_INIT and struct sdei_crosscall_args are only visible to sdei_do_{cross, local}_call(). Signed-off-by: Gavin Shan <gshan@redhat.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: James Morse <james.morse@arm.com> Link: https://lore.kernel.org/r/20200922130423.10173-12-gshan@redhat.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent a27c04e commit f467362

1 file changed

Lines changed: 25 additions & 16 deletions

File tree

drivers/firmware/arm_sdei.c

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,17 @@ struct sdei_crosscall_args {
8585
atomic_set(&arg.errors, 0); \
8686
} while (0)
8787

88+
static inline int sdei_do_local_call(smp_call_func_t fn,
89+
struct sdei_event *event)
90+
{
91+
struct sdei_crosscall_args arg;
92+
93+
CROSSCALL_INIT(arg, event);
94+
fn(&arg);
95+
96+
return arg.first_error;
97+
}
98+
8899
static inline int sdei_do_cross_call(smp_call_func_t fn,
89100
struct sdei_event *event)
90101
{
@@ -677,20 +688,19 @@ static int sdei_reregister_shared(void)
677688
static int sdei_cpuhp_down(unsigned int cpu)
678689
{
679690
struct sdei_event *event;
680-
struct sdei_crosscall_args arg;
691+
int err;
681692

682693
/* un-register private events */
683694
spin_lock(&sdei_list_lock);
684695
list_for_each_entry(event, &sdei_list, list) {
685696
if (event->type == SDEI_EVENT_TYPE_SHARED)
686697
continue;
687698

688-
CROSSCALL_INIT(arg, event);
689-
/* call the cross-call function locally... */
690-
_local_event_unregister(&arg);
691-
if (arg.first_error)
699+
err = sdei_do_local_call(_local_event_unregister, event);
700+
if (err) {
692701
pr_err("Failed to unregister event %u: %d\n",
693-
event->event_num, arg.first_error);
702+
event->event_num, err);
703+
}
694704
}
695705
spin_unlock(&sdei_list_lock);
696706

@@ -700,7 +710,7 @@ static int sdei_cpuhp_down(unsigned int cpu)
700710
static int sdei_cpuhp_up(unsigned int cpu)
701711
{
702712
struct sdei_event *event;
703-
struct sdei_crosscall_args arg;
713+
int err;
704714

705715
/* re-register/enable private events */
706716
spin_lock(&sdei_list_lock);
@@ -709,20 +719,19 @@ static int sdei_cpuhp_up(unsigned int cpu)
709719
continue;
710720

711721
if (event->reregister) {
712-
CROSSCALL_INIT(arg, event);
713-
/* call the cross-call function locally... */
714-
_local_event_register(&arg);
715-
if (arg.first_error)
722+
err = sdei_do_local_call(_local_event_register, event);
723+
if (err) {
716724
pr_err("Failed to re-register event %u: %d\n",
717-
event->event_num, arg.first_error);
725+
event->event_num, err);
726+
}
718727
}
719728

720729
if (event->reenable) {
721-
CROSSCALL_INIT(arg, event);
722-
_local_event_enable(&arg);
723-
if (arg.first_error)
730+
err = sdei_do_local_call(_local_event_enable, event);
731+
if (err) {
724732
pr_err("Failed to re-enable event %u: %d\n",
725-
event->event_num, arg.first_error);
733+
event->event_num, err);
734+
}
726735
}
727736
}
728737
spin_unlock(&sdei_list_lock);

0 commit comments

Comments
 (0)