Re: [PATCH v6 02/13] gpio: mxc: fix both_edges bit operations

From: Peng Fan

Date: Mon Oct 12 2026 - 05:47:56 EST


On Mon, Oct 12, 2026 at 12:18:33PM +0300, Andy Shevchenko wrote:
>On Sun, Oct 11, 2026 at 2:54 PM Peng Fan (OSS) <peng.fan@xxxxxxxxxxx> wrote:
>>
>> gpio_set_irq_type() can be called concurrently for different pins on
>> the same port. The IRQ core serializes per irq descriptor, but
>> different pins have different descriptors, so on SMP systems two
>> concurrent gpio_set_irq_type() calls for pins on the same port run
>> without mutual exclusion.
>>
>> The read-modify-write of port->both_edges is performed outside the
>> port-wide scoped_guard(gpio_generic_lock_irqsave) section, so
>> concurrent updates for different pins can overwrite each other,
>> causing missed interrupts or stuck IRQ lines on dual-edge triggered
>> pins.
>>
>> The original uniprocessor MXC SoCs were not affected; the race
>> became reachable on multi-core i.MX7 and i.MX8 SoCs that reuse this
>> driver.
>>
>> Convert both_edges from u32 to unsigned long and use set_bit(),
>> clear_bit(), and test_bit() to make the modifications atomic.
>
>Is bitops.h already included?

oh. fix in v7.

Thanks
Peng

>
>--
>With Best Regards,
>Andy Shevchenko
>