lib: sbi_ipi: Do not ignore errors from sbi_ipi_send()
authorSamuel Holland <samuel.holland@sifive.com>
Mon, 18 Dec 2023 12:43:45 +0000 (18:13 +0530)
committerAnup Patel <anup@brainfault.org>
Mon, 18 Dec 2023 13:56:11 +0000 (19:26 +0530)
Currently, failures in sbi_ipi_send() are silently ignored, which makes
them difficult to debug. Instead, abort sending the IPI and pass back
the error, but still synchronize any IPIs already sent.

Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
Signed-off-by: Anup Patel <anup@brainfault.org>
lib/sbi/sbi_ipi.c

index 5c33a78b2f3af6ac659802f2c6c04ea5cafa4b39..56ba743c5518e59686079d709fe05117a038a15e 100644 (file)
@@ -101,7 +101,7 @@ static int sbi_ipi_sync(struct sbi_scratch *scratch, u32 event)
  */
 int sbi_ipi_send_many(ulong hmask, ulong hbase, u32 event, void *data)
 {
-       int rc;
+       int rc = 0;
        bool retry_needed;
        ulong i, m;
        struct sbi_hartmask target_mask = {0};
@@ -135,17 +135,21 @@ int sbi_ipi_send_many(ulong hmask, ulong hbase, u32 event, void *data)
                retry_needed = false;
                sbi_hartmask_for_each_hartindex(i, &target_mask) {
                        rc = sbi_ipi_send(scratch, i, event, data);
+                       if (rc < 0)
+                               goto done;
                        if (rc == SBI_IPI_UPDATE_RETRY)
                                retry_needed = true;
                        else
                                sbi_hartmask_clear_hartindex(i, &target_mask);
+                       rc = 0;
                }
        } while (retry_needed);
 
+done:
        /* Sync IPIs */
        sbi_ipi_sync(scratch, event);
 
-       return 0;
+       return rc;
 }
 
 int sbi_ipi_event_create(const struct sbi_ipi_event_ops *ops)