On Mon, Feb 04, 2019 at 04:59:13PM -0500, John David Anglin wrote: > This change fixes a race condition in the setup of hardware irqs and the > code enabling PHY link detection in the mv88e6xxx driver. > > This race was observed on the espressobin board where the GPIO interrupt > controller only supports edge interrupts. If the INTn output pin goes low > before the GPIO interrupt is enabled, PHY link interrupts are not detected. > > With this change, we > 1) force INTn high by clearing all interrupt enables in global 1 control 1, > 2) setup the hardware irq, and then > 3) perform the remaining common setup. > > This simplifies the setup and allows some unnecessary code to be removed.
Hi Dave I took a closer look now. I don't actually see why the current code is wrong. mv88e6xxx_g1_irq_setup() calls mv88e6xxx_g1_irq_setup_common() and then registers the interrupt handler. mv88e6xxx_g1_irq_setup_common() does what you want, it masks all interrupts in the hardware and clears any pending interrupts which can be cleared. The change you made is actually dangerous. As soon as you request the interrupt, it is live, it can fire, and call mv88e6xxx_g1_irq_thread_work(). That needs the irq domain. But the change you made defers the creating of the domain until after the interrupt is registered. So we can de-refernece a NULL pointer in the interrupt handler. Andrew