All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] can: flexcan: fix chip freeze for missing bitrate
@ 2021-03-15 23:15 Angelo Dureghello
  2021-03-16  7:46 ` Marc Kleine-Budde
  0 siblings, 1 reply; 2+ messages in thread
From: Angelo Dureghello @ 2021-03-15 23:15 UTC (permalink / raw)
  To: wg; +Cc: qiangqing.zhang, mkl, linux-can, Angelo Dureghello

For cases when flexcan is built-in, bitrate is still not set
at registering. So flexcan_chip_freeze() generates:

[    1.860000] *** ZERO DIVIDE ***   FORMAT=4
[    1.860000] Current process id is 1
[    1.860000] BAD KERNEL TRAP: 00000000
[    1.860000] PC: [<402e70c8>] flexcan_chip_freeze+0x1a/0xa8

To allow chip freeze, using an hardcoded timeout when bitrate is still
not set.

Signed-off-by: Angelo Dureghello <angelo@kernel-space.org>
---
 drivers/net/can/flexcan.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 134c05757a3b..bb41ff3d2d1e 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -697,9 +697,13 @@ static int flexcan_chip_disable(struct flexcan_priv *priv)
 static int flexcan_chip_freeze(struct flexcan_priv *priv)
 {
 	struct flexcan_regs __iomem *regs = priv->regs;
-	unsigned int timeout = 1000 * 1000 * 10 / priv->can.bittiming.bitrate;
+	unsigned int timeout;
+	u32 bitrate = priv->can.bittiming.bitrate;
 	u32 reg;
 
+	timeout = bitrate ? 1000 * 1000 * 10 / bitrate :
+			FLEXCAN_TIMEOUT_US / 10;
+
 	reg = priv->read(&regs->mcr);
 	reg |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_HALT;
 	priv->write(reg, &regs->mcr);
-- 
2.30.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] can: flexcan: fix chip freeze for missing bitrate
  2021-03-15 23:15 [PATCH] can: flexcan: fix chip freeze for missing bitrate Angelo Dureghello
@ 2021-03-16  7:46 ` Marc Kleine-Budde
  0 siblings, 0 replies; 2+ messages in thread
From: Marc Kleine-Budde @ 2021-03-16  7:46 UTC (permalink / raw)
  To: Angelo Dureghello; +Cc: wg, qiangqing.zhang, linux-can

[-- Attachment #1: Type: text/plain, Size: 849 bytes --]

On 16.03.2021 00:15:10, Angelo Dureghello wrote:
> For cases when flexcan is built-in, bitrate is still not set
> at registering. So flexcan_chip_freeze() generates:
> 
> [    1.860000] *** ZERO DIVIDE ***   FORMAT=4
> [    1.860000] Current process id is 1
> [    1.860000] BAD KERNEL TRAP: 00000000
> [    1.860000] PC: [<402e70c8>] flexcan_chip_freeze+0x1a/0xa8
> 
> To allow chip freeze, using an hardcoded timeout when bitrate is still
> not set.
> 
> Signed-off-by: Angelo Dureghello <angelo@kernel-space.org>

Applied to linux-can/testing

Thanks,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-16  7:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-15 23:15 [PATCH] can: flexcan: fix chip freeze for missing bitrate Angelo Dureghello
2021-03-16  7:46 ` Marc Kleine-Budde

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.