diff options
| author | Xiang W <[email protected]> | 2023-11-22 20:54:38 +0800 |
|---|---|---|
| committer | Anup Patel <[email protected]> | 2023-12-08 17:07:03 +0530 |
| commit | 07419ec84bc39d476a17f8b1450434e57407600d (patch) | |
| tree | 6de1c0594dc9d2eca244805484a3411260163ed9 /lib | |
| parent | 88398696c816dfc79d5301180dfe42a5d8c497c9 (diff) | |
lib: sbi: Prevent redundant sbi_ipi_process
Multiple harts may try to send IPI to a particular target hart A
in which case the send_ipi() should be called only when the old
value of the hart A ipi_type is zero.
Signed-off-by: Xiang W <[email protected]>
Reviewed-by: Anup Patel <[email protected]>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sbi/sbi_ipi.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/sbi/sbi_ipi.c b/lib/sbi/sbi_ipi.c index 0bf446a0..5c33a78b 100644 --- a/lib/sbi/sbi_ipi.c +++ b/lib/sbi/sbi_ipi.c @@ -39,7 +39,7 @@ static const struct sbi_ipi_event_ops *ipi_ops_array[SBI_IPI_EVENT_MAX]; static int sbi_ipi_send(struct sbi_scratch *scratch, u32 remote_hartindex, u32 event, void *data) { - int ret; + int ret = 0; struct sbi_scratch *remote_scratch = NULL; struct sbi_ipi_data *ipi_data; const struct sbi_ipi_event_ops *ipi_ops; @@ -64,11 +64,15 @@ static int sbi_ipi_send(struct sbi_scratch *scratch, u32 remote_hartindex, /* * Set IPI type on remote hart's scratch area and - * trigger the interrupt + * trigger the interrupt. + * + * Multiple harts may be trying to send IPI to the + * remote hart so call sbi_ipi_raw_send() only when + * the ipi_type was previously zero. */ - atomic_raw_set_bit(event, &ipi_data->ipi_type); - - ret = sbi_ipi_raw_send(remote_hartindex); + if (!__atomic_fetch_or(&ipi_data->ipi_type, + BIT(event), __ATOMIC_RELAXED)) + ret = sbi_ipi_raw_send(remote_hartindex); sbi_pmu_ctr_incr_fw(SBI_PMU_FW_IPI_SENT); |
