Re: [PATCH v4 3/3] gpio: ws16c48: Migrate to the regmap API

From: William Breathitt Gray
Date: Tue Mar 07 2023 - 21:51:40 EST


On Mon, Mar 06, 2023 at 04:20:03PM +0200, Andy Shevchenko wrote:
> On Mon, Mar 06, 2023 at 07:59:53AM -0500, William Breathitt Gray wrote:
>
> ...
>
> > - raw_spinlock_t lock;
> > + spinlock_t lock;
>
> This is a regression.
> That said, do we need a support of raw spin locks in the regmap IRQ?

So this code has a similar need as the gpio-pcie-idio-24 patch: guard
registers between handle_mask_sync() and set_type_config(); however, now
we also need to protect registers in regmap_irq_thread(). We can't use a
mutex here because regmap_irq_thread() is executed in an interrupt
context so we cannot sleep.

This might be a mistake in my understanding: I chose spinlock_t here
because I believed it to map out to a raw_spinlock_t anyway underneath,
whereas on RT kernels it would map out to whatever the equivalent is. I
suspect this is not actually the case. Would using raw_spinlock_t
explicitly be the correct way to go for this particular case?

> > + u8 irq_mask[WS16C48_NUM_IRQS / WS16C48_NGPIO_PER_REG];
>
> Can this be a bitmap? Or is it too over engineered with it?

I also considered a bitmap at first, but I believe it adds an
unnecessary abstraction in this particular case: irq_mask is just a
buffer to hold the previous mask_buf state to check if it's changed when
ws16c48_handle_mask_sync() is called. Since all we do with it is save
the mask_buf directly, using the bitmap API seems like overkill.

William Breathitt Gray

Attachment: signature.asc
Description: PGP signature