Skip to content

Commit

Permalink
can: flexcan: fix shutdown: first disable chip, then all interrupts
Browse files Browse the repository at this point in the history
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.

Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  • Loading branch information
Marc Kleine-Budde committed Mar 3, 2014
1 parent 635d61a commit 5be93bd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/net/can/flexcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -827,14 +827,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, &regs->imask1);

/* Disable + halt module */
reg = flexcan_read(&regs->mcr);
reg |= FLEXCAN_MCR_MDIS | FLEXCAN_MCR_HALT;
flexcan_write(reg, &regs->mcr);

/* Disable all interrupts */
flexcan_write(0, &regs->imask1);
flexcan_write(priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_ALL,
&regs->ctrl);

if (priv->reg_xceiver)
regulator_disable(priv->reg_xceiver);
priv->can.state = CAN_STATE_STOPPED;
Expand Down

0 comments on commit 5be93bd

Please sign in to comment.