Hi Wolfram,

On Sat, 12 Sept 2026 at 21:20, Wolfram Sang
<[email protected]> wrote:
> To help debugging, offer a list of registered hwspinlocks in debugfs. It
> will also print the responsible hwspinlock_device and if the spinlock is
> currently used. It does not show if the lock is taken because of
> side-effects. Often, reading a lock means actually taking it.
>
> Signed-off-by: Wolfram Sang <[email protected]>

Thanks for your patch!

> --- a/drivers/hwspinlock/hwspinlock_core.c
> +++ b/drivers/hwspinlock/hwspinlock_core.c
> @@ -860,5 +862,70 @@ struct hwspinlock 
> *devm_hwspin_lock_request_specific(struct device *dev,
>  }
>  EXPORT_SYMBOL_GPL(devm_hwspin_lock_request_specific);
>
> +#ifdef CONFIG_DEBUG_FS
> +static void *hwspin_lock_seq_start(struct seq_file *s, loff_t *ppos)
> +{
> +       unsigned long index = *ppos;
> +       struct hwspinlock *hwlock;
> +
> +       rcu_read_lock();
> +       hwlock = xa_find(&hwspinlocks, &index, ULONG_MAX, XA_PRESENT);
> +       *ppos = index;
> +
> +       return hwlock;
> +}
> +
> +static void *hwspin_lock_seq_next(struct seq_file *s, void *v, loff_t *ppos)
> +{
> +       /* Increase ppos here to avoid endless loops. Don't use 
> xa_find_after() */

Do you mean xa_find_after() may loop forever?

> +       unsigned long index = *ppos + 1;
> +       struct hwspinlock *hwlock;
> +
> +       hwlock = xa_find(&hwspinlocks, &index, ULONG_MAX, XA_PRESENT);
> +       *ppos = index;
> +
> +       return hwlock;
> +}

> +static int hwspin_lock_seq_show(struct seq_file *s, void *v)
> +{
> +       struct hwspinlock *hwlock = v;
> +       bool unused = xa_get_mark(&hwspinlocks, s->index, HWSPINLOCK_UNUSED);
> +
> +       seq_printf(s, "%4llu:\t%s\t%s\n", s->index, unused ? "free" : "in 
> use",

For easier parsing the output, you may want to use a string without
spaces, e.g. "busy", "active", ...

> +                  dev_name(hwlock->bank->dev));
> +       return 0;
> +}

Reviewed-by: Geert Uytterhoeven <[email protected]>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Reply via email to