From: Marc Kleine-Budde Date: Wed, 19 Feb 2014 11:00:51 +0000 (+0100) Subject: can: flexcan: fix shutdown: first disable chip, then all interrupts X-Git-Tag: v3.12.15~16 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e32578deab8a4d815dbb7211b47f099fb00b4bd5;p=thirdparty%2Fkernel%2Fstable.git can: flexcan: fix shutdown: first disable chip, then all interrupts commit 5be93bdda64e85450598c6e97f79fb8f6acf30e0 upstream. When shutting down the CAN interface (ifconfig canX down) during high CAN bus loads, the CAN core might hang and freeze the whole CPU. This patch fixes the shutdown sequence by first disabling the CAN core then disabling all interrupts. Signed-off-by: Marc Kleine-Budde Signed-off-by: Jiri Slaby --- diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c index c1c3b132fed5e..26c8b2d80f7b0 100644 --- a/drivers/net/can/flexcan.c +++ b/drivers/net/can/flexcan.c @@ -824,14 +824,16 @@ static void flexcan_chip_stop(struct net_device *dev) struct flexcan_regs __iomem *regs = priv->base; u32 reg; - /* Disable all interrupts */ - flexcan_write(0, ®s->imask1); - /* Disable + halt module */ reg = flexcan_read(®s->mcr); reg |= FLEXCAN_MCR_MDIS | FLEXCAN_MCR_HALT; flexcan_write(reg, ®s->mcr); + /* Disable all interrupts */ + flexcan_write(0, ®s->imask1); + flexcan_write(priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_ALL, + ®s->ctrl); + if (priv->reg_xceiver) regulator_disable(priv->reg_xceiver); priv->can.state = CAN_STATE_STOPPED;