[PATCH 6/7] lib: sbi: dbtr: report the failing index of UPDATE
Himanshu Chauhan
himanshu.chauhan at oss.qualcomm.com
Mon Nov 23 22:34:44 PST 2026
On Sat, Nov 21, 2026 at 12:11:18AM +0100, Heinrich Schuchardt wrote:
> The specification says that sbi_debug_update_triggers() returns the
> array index i of the failing trigger configuration in sbiret.value, and
> zero on success, like sbi_debug_install_triggers().
>
> The update function had no output parameter and the ecall handler did
> not pass one, so sbiret.value was always zero. A failure in the second
> entry of a batch looked like a failure of the first one.
>
> Pass &out->value to sbi_dbtr_update_trig() and set it to the array index
> on every failure inside the loop.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
> ---
> include/sbi/sbi_dbtr.h | 2 +-
> lib/sbi/sbi_dbtr.c | 5 ++++-
> lib/sbi/sbi_ecall_dbtr.c | 2 +-
> 3 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/include/sbi/sbi_dbtr.h b/include/sbi/sbi_dbtr.h
> index 86af03f2..ab2038f2 100644
> --- a/include/sbi/sbi_dbtr.h
> +++ b/include/sbi/sbi_dbtr.h
> @@ -126,7 +126,7 @@ int sbi_dbtr_uninstall_trig(unsigned long trig_idx_base,
> int sbi_dbtr_enable_trig(unsigned long trig_idx_base,
> unsigned long trig_idx_mask);
> int sbi_dbtr_update_trig(unsigned long smode,
> - unsigned long trig_count);
> + unsigned long trig_count, unsigned long *out);
> int sbi_dbtr_disable_trig(unsigned long trig_idx_base,
> unsigned long trig_idx_mask);
>
> diff --git a/lib/sbi/sbi_dbtr.c b/lib/sbi/sbi_dbtr.c
> index 01b74f5f..a6b860da 100644
> --- a/lib/sbi/sbi_dbtr.c
> +++ b/lib/sbi/sbi_dbtr.c
> @@ -943,7 +943,7 @@ int sbi_dbtr_enable_trig(unsigned long trig_idx_base,
> }
>
> int sbi_dbtr_update_trig(unsigned long smode,
> - unsigned long trig_count)
> + unsigned long trig_count, unsigned long *out)
> {
> unsigned long trig_idx;
> struct sbi_dbtr_trigger *trig;
> @@ -973,6 +973,7 @@ int sbi_dbtr_update_trig(unsigned long smode,
> trig_idx = entry->id.idx;
>
> if (trig_idx >= hs->total_trigs) {
> + *out = _idx;
> sbi_hart_protection_temp_unmap_range((unsigned long)entry, sizeof(*entry));
> return SBI_ERR_INVALID_PARAM;
> }
> @@ -980,6 +981,7 @@ int sbi_dbtr_update_trig(unsigned long smode,
> trig = INDEX_TO_TRIGGER(trig_idx);
>
> if (!(trig->state & RV_DBTR_BIT_MASK(TS, MAPPED))) {
> + *out = _idx;
> sbi_hart_protection_temp_unmap_range((unsigned long)entry, sizeof(*entry));
> return SBI_ERR_FAILED;
> }
> @@ -987,6 +989,7 @@ int sbi_dbtr_update_trig(unsigned long smode,
> rc = dbtr_check_trigger_config(hs, trig, &entry->data,
> tdata2_impl, tdata3_impl);
> if (rc) {
> + *out = _idx;
> sbi_hart_protection_temp_unmap_range((unsigned long)entry, sizeof(*entry));
> return rc;
> }
> diff --git a/lib/sbi/sbi_ecall_dbtr.c b/lib/sbi/sbi_ecall_dbtr.c
> index 704af5a4..b86ce5b3 100644
> --- a/lib/sbi/sbi_ecall_dbtr.c
> +++ b/lib/sbi/sbi_ecall_dbtr.c
> @@ -43,7 +43,7 @@ static int sbi_ecall_dbtr_handler(unsigned long extid, unsigned long funcid,
> ret = sbi_dbtr_enable_trig(regs->a0, regs->a1);
> break;
> case SBI_EXT_DBTR_TRIGGER_UPDATE:
> - ret = sbi_dbtr_update_trig(smode, regs->a0);
> + ret = sbi_dbtr_update_trig(smode, regs->a0, &out->value);
> break;
> case SBI_EXT_DBTR_TRIGGER_DISABLE:
> ret = sbi_dbtr_disable_trig(regs->a0, regs->a1);
Looks good.
Reviewed-by: Himanshu Chauhan <himanshu.chauhan at oss.qualcomm.com>
> --
> 2.53.0
>
>
> --
> opensbi mailing list
> opensbi at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi
More information about the opensbi
mailing list