Message ID | 20210220231144.32325-1-kabel@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [mvebu-dt] ARM: dts: turris-omnia: configure LED[2]/INTn pin as interrupt pin | expand |
On Sun, Feb 21, 2021 at 12:11:44AM +0100, Marek Behún wrote: > Use the `marvell,reg-init` DT property to configure the LED[2]/INTn pin > of the Marvell 88E1514 ethernet PHY on Turris Omnia into interrupt mode. > > Without this the pin is by default in LED[2] mode, and the Marvell PHY > driver configures LED[2] into "On - Link, Blink - Activity" mode. > > This fixes the issue where the pca9538 GPIO/interrupt controller (which > can't mask interrupts in HW) received too many interrupts and after a > time started ignoring the interrupt with error message: > IRQ 71: nobody cared Hi Marek The pca9538 and alike are a poor choice for interrupts. As you said, you cannot mask interrupts, and input are interrupt sources. With this change, does it actually work reliably? It looks like all the inputs you have support polling. And because this devices is so unreliable with interrupts, interrupt support is mostly not built. I would not expect a distribution kernel to enable interrupt support for this driver. Does all the code correctly fall back to polling when interrupts are not available? So although the patch looks O.K, i'm just wonder if it is worth it, or the better fix is to remove the interrupt configuration from the pca9538 node. Andrew
On Sun, 21 Feb 2021 01:10:57 +0100 Andrew Lunn <andrew@lunn.ch> wrote: > On Sun, Feb 21, 2021 at 12:11:44AM +0100, Marek Behún wrote: > > Use the `marvell,reg-init` DT property to configure the LED[2]/INTn pin > > of the Marvell 88E1514 ethernet PHY on Turris Omnia into interrupt mode. > > > > Without this the pin is by default in LED[2] mode, and the Marvell PHY > > driver configures LED[2] into "On - Link, Blink - Activity" mode. > > > > This fixes the issue where the pca9538 GPIO/interrupt controller (which > > can't mask interrupts in HW) received too many interrupts and after a > > time started ignoring the interrupt with error message: > > IRQ 71: nobody cared > > Hi Marek > > The pca9538 and alike are a poor choice for interrupts. As you said, > you cannot mask interrupts, and input are interrupt sources. > > With this change, does it actually work reliably? It looks like all > the inputs you have support polling. And because this devices is so > unreliable with interrupts, interrupt support is mostly not built. I > would not expect a distribution kernel to enable interrupt support for > this driver. Does all the code correctly fall back to polling when > interrupts are not available? > > So although the patch looks O.K, i'm just wonder if it is worth it, or > the better fix is to remove the interrupt configuration from the > pca9538 node. > > Andrew Hi Andrew, - we already discussed this and you explained to me that pca9538 is poor as an interrupt source. That is why I did not send patch adding interrupt-source to the PHY node last time. We are polling the PHY for interrupts for now - I would like to try this though, and see whether it will cause problems. Unfortunately I forgot to do this last time - nonetheless the pin is connected as an interrupt on the board, so I think that the PHY driver should configure it that way, even if the INT signal is not used - removing the interrupts property from the pca9538 controller node would solve the issue as well. The other pins on the controller are used for SFP cage GPIOs and the way the pca953x driver is written, the GPIOs are polled anyway - the interrupt is not used for them All in all I think for now this solution is best (since the pin is _meant_ to be used as an interrupt pin on the board and the issue is solved by this patch). BTW do you have some experience where pca9538 or compatible cause errors when used for interrupts? Because I am thinking about trying to update the pca953x driver to support IRQs via the gpio_chip it registers, instead of a separate irq_chip. Marek
Hi, Marek, On Sat, 20 Feb 2021 at 23:12, Marek Behún <kabel@kernel.org> wrote: > > Use the `marvell,reg-init` DT property to configure the LED[2]/INTn pin > of the Marvell 88E1514 ethernet PHY on Turris Omnia into interrupt mode. > > Without this the pin is by default in LED[2] mode, and the Marvell PHY > driver configures LED[2] into "On - Link, Blink - Activity" mode. > > This fixes the issue where the pca9538 GPIO/interrupt controller (which > can't mask interrupts in HW) received too many interrupts and after a > time started ignoring the interrupt with error message: > IRQ 71: nobody cared > > There is a work in progress to have the Marvell PHY driver support > parsing PHY LED nodes from OF and registering the LEDs as Linux LED > class devices. Once this is done the PHY driver can also automatically > set the pin into INTn mode if it does not find LED[2] in OF. > > Until then, though, we fix this via `marvell,reg-init` DT property. > > Signed-off-by: Marek Behún <kabel@kernel.org> > Reported-by: Rui Salvaterra <rsalvaterra@gmail.com> > Fixes: 26ca8b52d6e1 ("ARM: dts: add support for Turris Omnia") > Cc: Uwe Kleine-König <uwe@kleine-koenig.org> > Cc: linux-arm-kernel@lists.infradead.org > Cc: Andrew Lunn <andrew@lunn.ch> > Cc: Gregory CLEMENT <gregory.clement@bootlin.com> > Cc: <stable@vger.kernel.org> > > --- > > This patch fixes bug introduced with the commit that added Turris > Omnia's DTS (26ca8b52d6e1), but will not apply cleanly because there is > commit 8ee4a5f4f40d which changed node name and node compatible > property and this commit did not go into stable. > > So either commit 8ee4a5f4f40d has also to go into stable before this, or > this patch has to be fixed a little in order to apply to 4.14+. > > Please let me know how should I handle this. > > --- > arch/arm/boot/dts/armada-385-turris-omnia.dts | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/arm/boot/dts/armada-385-turris-omnia.dts b/arch/arm/boot/dts/armada-385-turris-omnia.dts > index 646a06420c77..b0f3fd8e1429 100644 > --- a/arch/arm/boot/dts/armada-385-turris-omnia.dts > +++ b/arch/arm/boot/dts/armada-385-turris-omnia.dts > @@ -389,6 +389,7 @@ &mdio { > phy1: ethernet-phy@1 { > compatible = "ethernet-phy-ieee802.3-c22"; > reg = <1>; > + marvell,reg-init = <3 18 0 0x4985>; > > /* irq is connected to &pcawan pin 7 */ > }; > -- > 2.26.2 > This does seem to fix the problem on my Omnia. Feel free to add my Tested-by: Rui Salvaterra <rsalvaterra@gmail.com> Thanks, Rui
On Sun, Feb 21, 2021 at 12:11:44AM +0100, Marek Behún wrote: > Use the `marvell,reg-init` DT property to configure the LED[2]/INTn pin > of the Marvell 88E1514 ethernet PHY on Turris Omnia into interrupt mode. > > Without this the pin is by default in LED[2] mode, and the Marvell PHY > driver configures LED[2] into "On - Link, Blink - Activity" mode. > > This fixes the issue where the pca9538 GPIO/interrupt controller (which > can't mask interrupts in HW) received too many interrupts and after a > time started ignoring the interrupt with error message: > IRQ 71: nobody cared > > There is a work in progress to have the Marvell PHY driver support > parsing PHY LED nodes from OF and registering the LEDs as Linux LED > class devices. Once this is done the PHY driver can also automatically > set the pin into INTn mode if it does not find LED[2] in OF. > > Until then, though, we fix this via `marvell,reg-init` DT property. > > Signed-off-by: Marek Behún <kabel@kernel.org> > Reported-by: Rui Salvaterra <rsalvaterra@gmail.com> > Fixes: 26ca8b52d6e1 ("ARM: dts: add support for Turris Omnia") > Cc: Uwe Kleine-König <uwe@kleine-koenig.org> > Cc: linux-arm-kernel@lists.infradead.org > Cc: Andrew Lunn <andrew@lunn.ch> > Cc: Gregory CLEMENT <gregory.clement@bootlin.com> > Cc: <stable@vger.kernel.org> Hi Marek Reviewed-by: Andrew Lunn <andrew@lunn.ch> > This patch fixes bug introduced with the commit that added Turris > Omnia's DTS (26ca8b52d6e1), but will not apply cleanly because there is > commit 8ee4a5f4f40d which changed node name and node compatible > property and this commit did not go into stable. > > So either commit 8ee4a5f4f40d has also to go into stable before this, or > this patch has to be fixed a little in order to apply to 4.14+. Once this has made it into Linus's tree, you can give GregKH a version which will apply cleanly to 4.14. Reference the upstream version so they can be linked together. Andrew
On Sun, 21 Feb 2021 21:52:03 +0100 Andrew Lunn <andrew@lunn.ch> wrote: > > This patch fixes bug introduced with the commit that added Turris > > Omnia's DTS (26ca8b52d6e1), but will not apply cleanly because there is > > commit 8ee4a5f4f40d which changed node name and node compatible > > property and this commit did not go into stable. > > > > So either commit 8ee4a5f4f40d has also to go into stable before this, or > > this patch has to be fixed a little in order to apply to 4.14+. > > Once this has made it into Linus's tree, you can give GregKH a version > which will apply cleanly to 4.14. Reference the upstream version so > they can be linked together. Thank you, Andrew!
> BTW do you have some experience where pca9538 or compatible cause > errors when used for interrupts? Because I am thinking about trying > to update the pca953x driver to support IRQs via the gpio_chip it > registers, instead of a separate irq_chip. I had a board which just died at boot with an interrupt storm. It was probably a PCA9554, at least, i have that datasheet in my collection. First off, the hardware needs to designed correctly. All unused pins need a pull up/down since they default to inputs, and hence will trigger interrupts. Or you need to make unused pins outputs before you enable interrupts. And that probably goes against the design of the GPIO subsystem. I don't think you actually know when a pin is unused. I'm not sure i would want to touch this driver. Given how badly this device implements interrupts, any board which does successfully use it for interrupts might regress if you make code changes. And then you are going to have to try to figure out what you actually changed and why it regressed. Andrew
On Sun, 21 Feb 2021 22:18:48 +0100 Andrew Lunn <andrew@lunn.ch> wrote: > > BTW do you have some experience where pca9538 or compatible cause > > errors when used for interrupts? Because I am thinking about trying > > to update the pca953x driver to support IRQs via the gpio_chip it > > registers, instead of a separate irq_chip. > > I had a board which just died at boot with an interrupt storm. It was > probably a PCA9554, at least, i have that datasheet in my collection. But why did an interrupt storm kill it? The interrupt handler was called too many times? > First off, the hardware needs to designed correctly. All unused pins > need a pull up/down since they default to inputs, and hence will > trigger interrupts. Or you need to make unused pins outputs before you > enable interrupts. And that probably goes against the design of the > GPIO subsystem. I don't think you actually know when a pin is unused. Omnia has proper pull ups/downs on all 8 pins on this device. 5 of these pins are used from SFP cage, 1 as interrupt from PHY and 2 are unused. Only the interrupt pin was causing problems because marvell PHY driver configured it as blink on activity LED. > I'm not sure i would want to touch this driver. Given how badly this > device implements interrupts, any board which does successfully use it > for interrupts might regress if you make code changes. And then you > are going to have to try to figure out what you actually changed and > why it regressed. The problem in this driver is: - interrupt handler is called every time an input pin changes - not all input pins must be used as interrupt sources - if at least one input pin is used as an interrupt source, the interrupt handler is being called on every change of every input pin - but if the change occurs on a pin that is not used as an interrupt source, the interrupt handler returns IRQ_NONE - a simple scenario to achieve error: 1. use pin P0 as interrupt source and P1 as GPIO input; other pins as outputs 2. connect P1 to something that changes value 3. after 10000 changes of P1 (more if there was a change on P0 at the same time) the interrupt handler will return IRQ_NONE 10000 times and kernel will start ignoring interrupts from this driver because it was returning IRQ_NONE I think this needs to be fixed in this driver. Either this function should return IRQ_HANDLED in this case, or there should be a third option to return, something like IRQ_NONE_BUT_THATS_OK Marek
Hi Marek, > Use the `marvell,reg-init` DT property to configure the LED[2]/INTn pin > of the Marvell 88E1514 ethernet PHY on Turris Omnia into interrupt mode. > > Without this the pin is by default in LED[2] mode, and the Marvell PHY > driver configures LED[2] into "On - Link, Blink - Activity" mode. > > This fixes the issue where the pca9538 GPIO/interrupt controller (which > can't mask interrupts in HW) received too many interrupts and after a > time started ignoring the interrupt with error message: > IRQ 71: nobody cared > > There is a work in progress to have the Marvell PHY driver support > parsing PHY LED nodes from OF and registering the LEDs as Linux LED > class devices. Once this is done the PHY driver can also automatically > set the pin into INTn mode if it does not find LED[2] in OF. > > Until then, though, we fix this via `marvell,reg-init` DT property. > > Signed-off-by: Marek Behún <kabel@kernel.org> > Reported-by: Rui Salvaterra <rsalvaterra@gmail.com> > Fixes: 26ca8b52d6e1 ("ARM: dts: add support for Turris Omnia") > Cc: Uwe Kleine-König <uwe@kleine-koenig.org> > Cc: linux-arm-kernel@lists.infradead.org > Cc: Andrew Lunn <andrew@lunn.ch> > Cc: Gregory CLEMENT <gregory.clement@bootlin.com> > Cc: <stable@vger.kernel.org> Applied on mvebu/fixes Thanks, Gregory > > --- > > This patch fixes bug introduced with the commit that added Turris > Omnia's DTS (26ca8b52d6e1), but will not apply cleanly because there is > commit 8ee4a5f4f40d which changed node name and node compatible > property and this commit did not go into stable. > > So either commit 8ee4a5f4f40d has also to go into stable before this, or > this patch has to be fixed a little in order to apply to 4.14+. > > Please let me know how should I handle this. > > --- > arch/arm/boot/dts/armada-385-turris-omnia.dts | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/arm/boot/dts/armada-385-turris-omnia.dts b/arch/arm/boot/dts/armada-385-turris-omnia.dts > index 646a06420c77..b0f3fd8e1429 100644 > --- a/arch/arm/boot/dts/armada-385-turris-omnia.dts > +++ b/arch/arm/boot/dts/armada-385-turris-omnia.dts > @@ -389,6 +389,7 @@ &mdio { > phy1: ethernet-phy@1 { > compatible = "ethernet-phy-ieee802.3-c22"; > reg = <1>; > + marvell,reg-init = <3 18 0 0x4985>; > > /* irq is connected to &pcawan pin 7 */ > }; > -- > 2.26.2 >
diff --git a/arch/arm/boot/dts/armada-385-turris-omnia.dts b/arch/arm/boot/dts/armada-385-turris-omnia.dts index 646a06420c77..b0f3fd8e1429 100644 --- a/arch/arm/boot/dts/armada-385-turris-omnia.dts +++ b/arch/arm/boot/dts/armada-385-turris-omnia.dts @@ -389,6 +389,7 @@ &mdio { phy1: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + marvell,reg-init = <3 18 0 0x4985>; /* irq is connected to &pcawan pin 7 */ };
Use the `marvell,reg-init` DT property to configure the LED[2]/INTn pin of the Marvell 88E1514 ethernet PHY on Turris Omnia into interrupt mode. Without this the pin is by default in LED[2] mode, and the Marvell PHY driver configures LED[2] into "On - Link, Blink - Activity" mode. This fixes the issue where the pca9538 GPIO/interrupt controller (which can't mask interrupts in HW) received too many interrupts and after a time started ignoring the interrupt with error message: IRQ 71: nobody cared There is a work in progress to have the Marvell PHY driver support parsing PHY LED nodes from OF and registering the LEDs as Linux LED class devices. Once this is done the PHY driver can also automatically set the pin into INTn mode if it does not find LED[2] in OF. Until then, though, we fix this via `marvell,reg-init` DT property. Signed-off-by: Marek Behún <kabel@kernel.org> Reported-by: Rui Salvaterra <rsalvaterra@gmail.com> Fixes: 26ca8b52d6e1 ("ARM: dts: add support for Turris Omnia") Cc: Uwe Kleine-König <uwe@kleine-koenig.org> Cc: linux-arm-kernel@lists.infradead.org Cc: Andrew Lunn <andrew@lunn.ch> Cc: Gregory CLEMENT <gregory.clement@bootlin.com> Cc: <stable@vger.kernel.org> --- This patch fixes bug introduced with the commit that added Turris Omnia's DTS (26ca8b52d6e1), but will not apply cleanly because there is commit 8ee4a5f4f40d which changed node name and node compatible property and this commit did not go into stable. So either commit 8ee4a5f4f40d has also to go into stable before this, or this patch has to be fixed a little in order to apply to 4.14+. Please let me know how should I handle this. --- arch/arm/boot/dts/armada-385-turris-omnia.dts | 1 + 1 file changed, 1 insertion(+)