@@ -17,7 +17,7 @@ unsigned long sbi_spec_version __ro_after_init = SBI_SPEC_VERSION_DEFAULT;
1717EXPORT_SYMBOL (sbi_spec_version );
1818
1919static void (* __sbi_set_timer )(uint64_t stime ) __ro_after_init ;
20- static int (* __sbi_send_ipi )(const struct cpumask * cpu_mask ) __ro_after_init ;
20+ static void (* __sbi_send_ipi )(unsigned int cpu ) __ro_after_init ;
2121static int (* __sbi_rfence )(int fid , const struct cpumask * cpu_mask ,
2222 unsigned long start , unsigned long size ,
2323 unsigned long arg4 , unsigned long arg5 ) __ro_after_init ;
@@ -130,17 +130,6 @@ void sbi_shutdown(void)
130130}
131131EXPORT_SYMBOL (sbi_shutdown );
132132
133- /**
134- * sbi_clear_ipi() - Clear any pending IPIs for the calling hart.
135- *
136- * Return: None
137- */
138- void sbi_clear_ipi (void )
139- {
140- sbi_ecall (SBI_EXT_0_1_CLEAR_IPI , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
141- }
142- EXPORT_SYMBOL (sbi_clear_ipi );
143-
144133/**
145134 * __sbi_set_timer_v01() - Program the timer for next timer event.
146135 * @stime_value: The value after which next timer event should fire.
@@ -157,17 +146,12 @@ static void __sbi_set_timer_v01(uint64_t stime_value)
157146#endif
158147}
159148
160- static int __sbi_send_ipi_v01 (const struct cpumask * cpu_mask )
149+ static void __sbi_send_ipi_v01 (unsigned int cpu )
161150{
162- unsigned long hart_mask ;
163-
164- if (!cpu_mask || cpumask_empty (cpu_mask ))
165- cpu_mask = cpu_online_mask ;
166- hart_mask = __sbi_v01_cpumask_to_hartmask (cpu_mask );
167-
151+ unsigned long hart_mask =
152+ __sbi_v01_cpumask_to_hartmask (cpumask_of (cpu ));
168153 sbi_ecall (SBI_EXT_0_1_SEND_IPI , 0 , (unsigned long )(& hart_mask ),
169154 0 , 0 , 0 , 0 , 0 );
170- return 0 ;
171155}
172156
173157static int __sbi_rfence_v01 (int fid , const struct cpumask * cpu_mask ,
@@ -216,12 +200,10 @@ static void __sbi_set_timer_v01(uint64_t stime_value)
216200 sbi_major_version (), sbi_minor_version ());
217201}
218202
219- static int __sbi_send_ipi_v01 (const struct cpumask * cpu_mask )
203+ static void __sbi_send_ipi_v01 (unsigned int cpu )
220204{
221205 pr_warn ("IPI extension is not available in SBI v%lu.%lu\n" ,
222206 sbi_major_version (), sbi_minor_version ());
223-
224- return 0 ;
225207}
226208
227209static int __sbi_rfence_v01 (int fid , const struct cpumask * cpu_mask ,
@@ -248,55 +230,18 @@ static void __sbi_set_timer_v02(uint64_t stime_value)
248230#endif
249231}
250232
251- static int __sbi_send_ipi_v02 (const struct cpumask * cpu_mask )
233+ static void __sbi_send_ipi_v02 (unsigned int cpu )
252234{
253- unsigned long hartid , cpuid , hmask = 0 , hbase = 0 , htop = 0 ;
254- struct sbiret ret = {0 };
255235 int result ;
236+ struct sbiret ret = {0 };
256237
257- if (!cpu_mask || cpumask_empty (cpu_mask ))
258- cpu_mask = cpu_online_mask ;
259-
260- for_each_cpu (cpuid , cpu_mask ) {
261- hartid = cpuid_to_hartid_map (cpuid );
262- if (hmask ) {
263- if (hartid + BITS_PER_LONG <= htop ||
264- hbase + BITS_PER_LONG <= hartid ) {
265- ret = sbi_ecall (SBI_EXT_IPI ,
266- SBI_EXT_IPI_SEND_IPI , hmask ,
267- hbase , 0 , 0 , 0 , 0 );
268- if (ret .error )
269- goto ecall_failed ;
270- hmask = 0 ;
271- } else if (hartid < hbase ) {
272- /* shift the mask to fit lower hartid */
273- hmask <<= hbase - hartid ;
274- hbase = hartid ;
275- }
276- }
277- if (!hmask ) {
278- hbase = hartid ;
279- htop = hartid ;
280- } else if (hartid > htop ) {
281- htop = hartid ;
282- }
283- hmask |= BIT (hartid - hbase );
284- }
285-
286- if (hmask ) {
287- ret = sbi_ecall (SBI_EXT_IPI , SBI_EXT_IPI_SEND_IPI ,
288- hmask , hbase , 0 , 0 , 0 , 0 );
289- if (ret .error )
290- goto ecall_failed ;
238+ ret = sbi_ecall (SBI_EXT_IPI , SBI_EXT_IPI_SEND_IPI ,
239+ 1UL , cpuid_to_hartid_map (cpu ), 0 , 0 , 0 , 0 );
240+ if (ret .error ) {
241+ result = sbi_err_map_linux_errno (ret .error );
242+ pr_err ("%s: hbase = [%lu] failed (error [%d])\n" ,
243+ __func__ , cpuid_to_hartid_map (cpu ), result );
291244 }
292-
293- return 0 ;
294-
295- ecall_failed :
296- result = sbi_err_map_linux_errno (ret .error );
297- pr_err ("%s: hbase = [%lu] hmask = [0x%lx] failed (error [%d])\n" ,
298- __func__ , hbase , hmask , result );
299- return result ;
300245}
301246
302247static int __sbi_rfence_v02_call (unsigned long fid , unsigned long hmask ,
@@ -410,13 +355,11 @@ void sbi_set_timer(uint64_t stime_value)
410355
411356/**
412357 * sbi_send_ipi() - Send an IPI to any hart.
413- * @cpu_mask: A cpu mask containing all the target harts.
414- *
415- * Return: 0 on success, appropriate linux error code otherwise.
358+ * @cpu: Logical id of the target CPU.
416359 */
417- int sbi_send_ipi (const struct cpumask * cpu_mask )
360+ void sbi_send_ipi (unsigned int cpu )
418361{
419- return __sbi_send_ipi (cpu_mask );
362+ __sbi_send_ipi (cpu );
420363}
421364EXPORT_SYMBOL (sbi_send_ipi );
422365
@@ -641,21 +584,6 @@ long sbi_get_mimpid(void)
641584}
642585EXPORT_SYMBOL_GPL (sbi_get_mimpid );
643586
644- static void sbi_send_cpumask_ipi (const struct cpumask * target )
645- {
646- sbi_send_ipi (target );
647- }
648-
649- static void sbi_ipi_clear (void )
650- {
651- csr_clear (CSR_IP , IE_SIE );
652- }
653-
654- static const struct riscv_ipi_ops sbi_ipi_ops = {
655- .ipi_inject = sbi_send_cpumask_ipi ,
656- .ipi_clear = sbi_ipi_clear
657- };
658-
659587void __init sbi_init (void )
660588{
661589 int ret ;
@@ -702,6 +630,4 @@ void __init sbi_init(void)
702630 __sbi_send_ipi = __sbi_send_ipi_v01 ;
703631 __sbi_rfence = __sbi_rfence_v01 ;
704632 }
705-
706- riscv_set_ipi_ops (& sbi_ipi_ops );
707633}
0 commit comments