On Wed, Mar 08, 2023 at 03:06:18PM +0200, Andy Shevchenko wrote: > On Tue, Mar 07, 2023 at 09:51:26PM -0500, William Breathitt Gray wrote: > > 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? > > You may read the commit message of the 27d9098cff6e ("pinctrl: intel: > Use raw_spinlock for locking"). TL;DR: this is only affects IRQ chips, > so if your GPIO controller is _not_ an IRQ chip, you are fine. > > WRT the other driver, can_sleep may reduce scope of the use of GPIOs > and even make a regression if any consumer don't want that behaviour > and currently works. Looking through kernel/irq/manage.c, I see the raw_spinlock desc->lock is taken in __setup_irq() before potentially calling __irq_set_trigger() which ultimate calls the chip->irq_set_type() callback. So it seems unsafe to sleep within at least this callback which is utilized by both drivers, so both gpio-pcie-idio-24 and gpio-ws16c48 will need the raw_spinlock lock type afterall. I'll make the necessary changes and release a v5 of this patchset. As an aside, I wonder if locking is not needed if we only utilize the set_type_config() callback, because the desc->lock taken by the irq subsystem will be enough to guard between regmap_irq_set_type() and regmap_irq_thread(). It's not valid for our particular case here because we also utilize a handle_mask_sync() callback (chip_bus_lock() is not protected by desc->chip) but it's something to think about. William Breathitt Gray
Attachment:
signature.asc
Description: PGP signature