Skip to contentSkip to conversation

can: flexcan: add correctable errors correction when HW supports ECC

PATCH RESEND New Joakim Zhang 3 participants 14 messages Apr 16, 2020 – Sep 16, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 can: flexcan: add correctable errors correction when HW supports ECC

commit cdce844865be ("can: flexcan: add vf610 support for FlexCAN") From above commit by Stefan Agner, the patch just disables non-correctable errors interrupt and freeze mode. It still can correct the correctable errors since ECC enabled by default after reset (MECR[ECCDIS]=0, enable memory error correct) if HW supports ECC.

commit 5e269324db5a ("can: flexcan: disable completely the ECC mechanism") From above commit by Joakim Zhang, the patch disables ECC completely (assert MECR[ECCDIS]) according to the explanation of FLEXCAN_QUIRK_DISABLE_MECR that disable memory error detection. This cause correctable errors cannot be corrected even HW supports ECC.

The error correction mechanism ensures that in this 13-bit word, errors in one bit can be corrected (correctable errors) and errors in two bits can be detected but not corrected (non-correctable errors). Errors in more than two bits may not be detected.

If HW supports ECC, we can use this to correct the correctable errors detected from FlexCAN memory. Then disable non-correctable errors interrupt and freeze mode to avoid that put FlexCAN in freeze mode.

This patch adds correctable errors correction when HW supports ECC, and modify explanation for FLEXCAN_QUIRK_DISABLE_MECR.

---
 drivers/net/can/flexcan.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
drivers/net/can/flexcan.c +18 -5
index 3a754355ebe6..aa871953003a 100644
@@ -187,7 +187,7 @@
 #define FLEXCAN_QUIRK_BROKEN_WERR_STATE	BIT(1) /* [TR]WRN_INT not connected */
 #define FLEXCAN_QUIRK_DISABLE_RXFG	BIT(2) /* Disable RX FIFO Global mask */
 #define FLEXCAN_QUIRK_ENABLE_EACEN_RRS	BIT(3) /* Enable EACEN and RRS bit in ctrl2 */
-#define FLEXCAN_QUIRK_DISABLE_MECR	BIT(4) /* Disable Memory error detection */
+#define FLEXCAN_QUIRK_DISABLE_MECR	BIT(4) /* Disable non-correctable errors interrupt and freeze mode */
 #define FLEXCAN_QUIRK_USE_OFF_TIMESTAMP	BIT(5) /* Use timestamp based offloading */
 #define FLEXCAN_QUIRK_BROKEN_PERR_STATE	BIT(6) /* No interrupt for error passive */
 #define FLEXCAN_QUIRK_DEFAULT_BIG_ENDIAN	BIT(7) /* default to BE register access */
@@ -1203,8 +1203,8 @@ static int flexcan_chip_start(struct net_device *dev)
 	for (i = 0; i < priv->mb_count; i++)
 		priv->write(0, &regs->rximr[i]);
 
-	/* On Vybrid, disable memory error detection interrupts
-	 * and freeze mode.
+	/* On Vybrid, disable non-correctable errors interrupt and freeze
+	 * mode. It still can correct the correctable errors when HW supports ECC.
 	 * This also works around errata e5295 which generates
 	 * false positive memory errors and put the device in
 	 * freeze mode.
@@ -1212,19 +1212,32 @@ static int flexcan_chip_start(struct net_device *dev)
 	if (priv->devtype_data->quirks & FLEXCAN_QUIRK_DISABLE_MECR) {
 		/* Follow the protocol as described in "Detection
 		 * and Correction of Memory Errors" to write to
-		 * MECR register
+		 * MECR register (step 1 - 5)
+		 * 1. By default, CTRL2[ECRWRE] = 0, MECR[ECRWRDIS] = 1
+		 * 2. set CTRL2[ECRWRE]
 		 */
 		reg_ctrl2 = priv->read(&regs->ctrl2);
 		reg_ctrl2 |= FLEXCAN_CTRL2_ECRWRE;
 		priv->write(reg_ctrl2, &regs->ctrl2);
 
+		/* 3. clear MECR[ECRWRDIS] */
 		reg_mecr = priv->read(&regs->mecr);
 		reg_mecr &= ~FLEXCAN_MECR_ECRWRDIS;
 		priv->write(reg_mecr, &regs->mecr);
-		reg_mecr |= FLEXCAN_MECR_ECCDIS;
+
+		/* 4. all writes to MECR must keep MECR[ECRWRDIS] cleared */
 		reg_mecr &= ~(FLEXCAN_MECR_NCEFAFRZ | FLEXCAN_MECR_HANCEI_MSK |
 			      FLEXCAN_MECR_FANCEI_MSK);
 		priv->write(reg_mecr, &regs->mecr);
+
+		/* 5. after configuration done, lock MECR by either setting
+		 * MECR[ECRWRDIS] or clearing CTRL2[ECRWRE]
+		 */
+		reg_mecr |= FLEXCAN_MECR_ECRWRDIS;
+		priv->write(reg_mecr, &regs->mecr);
+		reg_ctrl2 &= ~FLEXCAN_CTRL2_ECRWRE;
+		priv->write(reg_ctrl2, &regs->ctrl2);
+
 	}
 
 	err = flexcan_transceiver_enable(priv);
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 can: flexcan: fix TDC feature

We enable TDC feature in flexcan_set_bittiming when loopback off, but disable it by mistake after calling flexcan_set_bittiming.

---
 drivers/net/can/flexcan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/can/flexcan.c +2 -1
index b16b8abc1c2c..27f4541d9400 100644
@@ -1202,6 +1202,8 @@ static void flexcan_set_bittiming(struct net_device *dev)
 				/* for the TDC to work reliably, the offset has to use optimal settings */
 				reg_fdctrl |= FLEXCAN_FDCTRL_TDCOFF(((dbt->phase_seg1 - 1) + dbt->prop_seg + 2) *
 								    ((dbt->brp -1) + 1));
+			} else {
+				reg_fdctrl &= ~FLEXCAN_FDCTRL_TDCEN;
 			}
 			priv->write(reg_fdctrl, &regs->fdctrl);
 
@@ -1354,7 +1356,6 @@ static int flexcan_chip_start(struct net_device *dev)
 	/* FDCTRL */
 	if (priv->can.ctrlmode_supported & CAN_CTRLMODE_FD) {
 		reg_fdctrl = priv->read(&regs->fdctrl) & ~FLEXCAN_FDCTRL_FDRATE;
-		reg_fdctrl &= ~FLEXCAN_FDCTRL_TDCEN;
 		reg_fdctrl &= ~(FLEXCAN_FDCTRL_MBDSR1(0x3) | FLEXCAN_FDCTRL_MBDSR0(0x3));
 		reg_mcr = priv->read(&regs->mcr) & ~FLEXCAN_MCR_FDEN;
 		reg_ctrl2 = priv->read(&regs->ctrl2) & ~FLEXCAN_CTRL2_ISOCANFDEN;
Signature · 1 line
2.17.1
author Tested-by Michael Walle on v1 1/1
#2 lore raw

RE: [PATCH linux-can-next/flexcan] can: flexcan: fix TDC feature

Hi Marc,

How about FlexCAN FD patch set, it is pending for a long time. Many work would base on it, we are happy to see it in upstream mainline ASAP.

Michael Walle also gives out the test-by tag:

Best Regards,
Joakim Zhang

Quoted 43 lines

-----Original Message-----
From: Joakim Zhang <[email protected]>
Sent: 2020年4月16日 17:31
To: [email protected]; [email protected]
Cc: dl-linux-imx <[email protected]>; [email protected]
Subject: [PATCH linux-can-next/flexcan] can: flexcan: fix TDC feature

We enable TDC feature in flexcan_set_bittiming when loopback off, but disable it by mistake after calling flexcan_set_bittiming.

---
 drivers/net/can/flexcan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/can/flexcan.c index renamed from drivers/net/can/flexcan.c +0 -0

b16b8abc1c2c..27f4541d9400 100644

drivers/net/can/flexcan.c +0 -0
@@ -1202,6 +1202,8 @@ static void flexcan_set_bittiming(struct net_device
 *dev)
 				/* for the TDC to work reliably, the offset has to use

optimal settings */
reg_fdctrl |=
FLEXCAN_FDCTRL_TDCOFF(((dbt->phase_seg1 - 1) + dbt->prop_seg + 2) *

drivers/net/can/flexcan.c +2 -1
 								    ((dbt->brp -1) + 1));
+			} else {
+				reg_fdctrl &= ~FLEXCAN_FDCTRL_TDCEN;
 			}
 			priv->write(reg_fdctrl, &regs->fdctrl);
@@ -1354,7 +1356,6 @@ static int flexcan_chip_start(struct net_device *dev)
 	/* FDCTRL */
 	if (priv->can.ctrlmode_supported & CAN_CTRLMODE_FD) {
 		reg_fdctrl = priv->read(&regs->fdctrl) & ~FLEXCAN_FDCTRL_FDRATE;
-		reg_fdctrl &= ~FLEXCAN_FDCTRL_TDCEN;
 		reg_fdctrl &= ~(FLEXCAN_FDCTRL_MBDSR1(0x3) |
 FLEXCAN_FDCTRL_MBDSR0(0x3));
 		reg_mcr = priv->read(&regs->mcr) & ~FLEXCAN_MCR_FDEN;

reg_ctrl2 = priv->read(&regs->ctrl2) &
~FLEXCAN_CTRL2_ISOCANFDEN;
--
2.17.1

#3 lore raw

Re: [PATCH linux-can-next/flexcan] can: flexcan: fix TDC feature

Hi Marc,

Am 2020-04-16 11:41, schrieb Joakim Zhang:

Quoted 8 lines

Hi Marc,

How about FlexCAN FD patch set, it is pending for a long time. Many work would base on it, we are happy to see it in upstream mainline ASAP.

Michael Walle also gives out the test-by tag:

There seems to be no activity for months here. Any reason for that? Is there anything we can do to speed things up?

-michael

#4 lore raw

Re: [PATCH linux-can-next/flexcan] can: flexcan: fix TDC feature

Am 2020-06-02 12:15, schrieb Michael Walle:

Quoted 9 lines

Hi Marc,

Am 2020-04-16 11:41, schrieb Joakim Zhang:

Quoted 6 lines

Hi Marc,

How about FlexCAN FD patch set, it is pending for a long time. Many work would base on it, we are happy to see it in upstream mainline ASAP.

Quoted 5 lines
Quoted 2 lines

Michael Walle also gives out the test-by tag:

There seems to be no activity for months here. Any reason for that? Is there anything we can do to speed things up?

ping.. There are no replies or anything. Sorry but this is really annoying and frustrating.

Marc, is there anything wrong with the flexcan patches?

-michael

#5 lore raw

Re: [PATCH linux-can-next/flexcan] can: flexcan: fix TDC feature

Quoted 13 lines · Michael Walle

Am 2020-06-02 12:15, schrieb Michael Walle:

Quoted 12 lines

Hi Marc,

Am 2020-04-16 11:41, schrieb Joakim Zhang:

Quoted 8 lines

Hi Marc,

How about FlexCAN FD patch set, it is pending for a long time. Many work would base on it, we are happy to see it in upstream mainline ASAP.

Michael Walle also gives out the test-by tag:

Quoted 7 lines
Quoted 2 lines

There seems to be no activity for months here. Any reason for that? Is there anything we can do to speed things up?

ping.. There are no replies or anything. Sorry but this is really annoying and frustrating.

Marc, is there anything wrong with the flexcan patches?

I've cleaned up the patches a bit, can you test this branch:

https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git/log/?h=flexcan

Marc

Signature · 4 lines
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 |
#6 lore raw

Re: [PATCH linux-can-next/flexcan] can: flexcan: fix TDC feature

Hi Marc,

Quoted 3 lines

I've cleaned up the patches a bit, can you test this branch:

https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git/log/?h=flexcan

This is working, but as Joakim already said, CAN-FD ISO mode is missing. It defaults to non-ISO mode, which is even worse, IMHO.

But I've also noticed a difference between the original patch and the one in that branch. When FD mode is enabled the original patch checks the priv->can.controlmode [1], the patch in the branch looks at priv->can.ctrlmode_supported instead [2], is that correct?

-michael

[1] https://lore.kernel.org/netdev/[email protected]/
[2] https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git/tree/drivers/net/can/flexcan.c?h=flexcan&id=5f097cd65cb2b42b88e6e1eb186f6a8f0c90559b#n1341

#7 lore raw

RE: [PATCH linux-can-next/flexcan] can: flexcan: fix TDC feature

Quoted 25 lines

-----Original Message-----
From: Michael Walle <[email protected]>
Sent: 2020年6月30日 0:23
To: Marc Kleine-Budde <[email protected]>
Cc: Joakim Zhang <[email protected]>; [email protected]; dl-linux-imx <[email protected]>; [email protected]
Subject: Re: [PATCH linux-can-next/flexcan] can: flexcan: fix TDC feature

Hi Marc,

Quoted 4 lines

I've cleaned up the patches a bit, can you test this branch:

https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.

kernel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Fmkl%2Flinux-can-next.g

Quoted 1 line

it%2Flog%2F%3Fh%3Dflexcan&amp;data=02%7C01%7Cqiangqing.zhang%40nx p.com

Quoted 1 line

%7C7c1d0ef7d8134c1a01dd08d81c48b55c%7C686ea1d3bc2b4c6fa92cd99c5

c301635

Quoted 1 line

%7C0%7C1%7C637290445925151654&amp;sdata=qYaM6gUoXED%2FcdHhR

kzZr9D1ev8t

Quoted 1 line

fIn2bj7knAZVaVw%3D&amp;reserved=0

Quoted 7 lines

This is working, but as Joakim already said, CAN-FD ISO mode is missing. It defaults to non-ISO mode, which is even worse, IMHO.

But I've also noticed a difference between the original patch and the one in that branch. When FD mode is enabled the original patch checks the priv->can.controlmode [1], the patch in the branch looks at priv->can.ctrlmode_supported instead [2], is that correct?

Hi Marc, Michael,

I have also noticed this difference, although this could not break function, but IMO, using priv->can.ctrlmode should be better.

Some nitpicks:
1) Can we use uniform check for HW which supports CAN FD in the driver, using priv->can.ctrlmode_supported instead of quirks?

drivers/net/can/flexcan.c +1 -1
@@ -1392,7 +1392,7 @@ static int flexcan_chip_start(struct net_device *dev)
                priv->write(reg_ctrl2, &regs->ctrl2);
        }
 
-       if ((priv->devtype_data->quirks & FLEXCAN_QUIRK_SUPPORT_FD)) {
+       if (priv->can.ctrlmode_supported & CAN_CTRLMODE_FD) {
                u32 reg_fdctrl;
 
                reg_fdctrl = priv->read(&regs->fdctrl);

Also delete the redundant parentheses here.

2) Clean timing register.

drivers/net/can/flexcan.c +15 -0
@@ -1167,6 +1167,14 @@ static void flexcan_set_bittiming_cbt(const struct net_device *dev)
        struct flexcan_regs __iomem *regs = priv->regs;
        u32 reg_cbt, reg_fdctrl;
 
+       reg_cbt = priv->read(&regs->cbt);
+       reg_cbt &= ~(FLEXCAN_CBT_BTF |
+               FIELD_PREP(FLEXCAN_CBT_EPRESDIV_MASK, 0x3ff) |
+               FIELD_PREP(FLEXCAN_CBT_ERJW_MASK, 0x1f) |
+               FIELD_PREP(FLEXCAN_CBT_EPROPSEG_MASK, 0x3f) |
+               FIELD_PREP(FLEXCAN_CBT_EPSEG1_MASK, 0x1f) |
+               FIELD_PREP(FLEXCAN_CBT_EPSEG2_MASK, 0x1f));
+
        /* CBT */
        /* CBT[EPSEG1] is 5 bit long and CBT[EPROPSEG] is 6 bit
         * long. The can_calc_bittiming() tries to divide the tseg1
@@ -1192,6 +1200,13 @@ static void flexcan_set_bittiming_cbt(const struct net_device *dev)
        if (priv->can.ctrlmode & CAN_CTRLMODE_FD) {
                u32 reg_fdcbt;
 
+               reg_fdcbt = priv->read(&regs->fdcbt);
+               reg_fdcbt &= ~(FIELD_PREP(FLEXCAN_FDCBT_FPRESDIV_MASK, 0x3ff) |
+                       FIELD_PREP(FLEXCAN_FDCBT_FRJW_MASK, 0x7) |
+                       FIELD_PREP(FLEXCAN_FDCBT_FPROPSEG_MASK, 0x1f) |
+                       FIELD_PREP(FLEXCAN_FDCBT_FPSEG1_MASK, 0x7) |
+                       FIELD_PREP(FLEXCAN_FDCBT_FPSEG2_MASK, 0x7));
+
                if (bt->brp != dbt->brp)
                        netdev_warn(dev, "Data brp=%d and brp=%d don't match, this may result in a phase error. Consider using different bitrate and/or data bitrate.\n",
                                    dbt->brp, bt->brp);

This is just my suggestion, to see if it is reasonable.

Best Regards,
Joakim Zhang

Quoted 18 lines

-michael

[1]
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.ker
nel.org%2Fnetdev%2F20190712075926.7357-4-qiangqing.zhang%40nxp.com% 2F&amp;data=02%7C01%7Cqiangqing.zhang%40nxp.com%7C7c1d0ef7d8134c 1a01dd08d81c48b55c%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C1%7 C637290445925151654&amp;sdata=hqF23aPWVEPsIuGvxiirnEdT6KHOULF%2F qBi7FaFY3tg%3D&amp;reserved=0
[2]
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kern
el.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Fmkl%2Flinux-can-next.git%2 Ftree%2Fdrivers%2Fnet%2Fcan%2Fflexcan.c%3Fh%3Dflexcan%26id%3D5f097c d65cb2b42b88e6e1eb186f6a8f0c90559b%23n1341&amp;data=02%7C01%7Cqi angqing.zhang%40nxp.com%7C7c1d0ef7d8134c1a01dd08d81c48b55c%7C686 ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C1%7C637290445925151654&amp; sdata=GWA7SqDA9tSi9mudKRC4G2nrLW4FjWJGXifJe8c3V0Q%3D&amp;reserv ed=0

#8 lore raw

Re: [PATCH linux-can-next/flexcan] can: flexcan: fix TDC feature

Quoted 10 lines · Joakim Zhang

I have also noticed this difference, although this could not break function, but IMO, using priv->can.ctrlmode should be better.

Some nitpicks:

1) Can we use uniform check for HW which supports CAN FD in the driver, using priv->can.ctrlmode_supported instead of quirks?>

drivers/net/can/flexcan.c static int flexcan_chip_start(struct net_device *dev) · line 1395

Quoted 5 lines
drivers/net/can/flexcan.c +1 -1
@@ -1392,7 +1392,7 @@ static int flexcan_chip_start(struct net_device *dev)
                priv->write(reg_ctrl2, &regs->ctrl2);
        }
 
-       if ((priv->devtype_data->quirks & FLEXCAN_QUIRK_SUPPORT_FD)) {
+       if (priv->can.ctrlmode_supported & CAN_CTRLMODE_FD) {

makes sense

Quoted 11 lines
drivers/net/can/flexcan.c +0 -0
                u32 reg_fdctrl;
 
                reg_fdctrl = priv->read(&regs->fdctrl);

Also delete the redundant parentheses here.

2) Clean timing register.

drivers/net/can/flexcan.c +0 -0
@@ -1167,6 +1167,14 @@ static void flexcan_set_bittiming_cbt(const struct net_device *dev)
        struct flexcan_regs __iomem *regs = priv->regs;

drivers/net/can/flexcan.c static void flexcan_set_bittiming_cbt(const struct net_device *dev) · line 1177

Quoted 10 lines
drivers/net/can/flexcan.c +8 -0
        u32 reg_cbt, reg_fdctrl;
 
+       reg_cbt = priv->read(&regs->cbt);
+       reg_cbt &= ~(FLEXCAN_CBT_BTF |
+               FIELD_PREP(FLEXCAN_CBT_EPRESDIV_MASK, 0x3ff) |
+               FIELD_PREP(FLEXCAN_CBT_ERJW_MASK, 0x1f) |
+               FIELD_PREP(FLEXCAN_CBT_EPROPSEG_MASK, 0x3f) |
+               FIELD_PREP(FLEXCAN_CBT_EPSEG1_MASK, 0x1f) |
+               FIELD_PREP(FLEXCAN_CBT_EPSEG2_MASK, 0x1f));
+

Why is this needed? The "reg_cbt &=" sets reg_cbt basically to 0, as the fields and the BTF occupy all 32bit.

The only thing that's left over is the read()....

Quoted 4 lines
drivers/net/can/flexcan.c +0 -0
        /* CBT */
        /* CBT[EPSEG1] is 5 bit long and CBT[EPROPSEG] is 6 bit
         * long. The can_calc_bittiming() tries to divide the tseg1

drivers/net/can/flexcan.c static void flexcan_set_bittiming_cbt(const struct net_device *dev) · line 1209

Quoted 10 lines
drivers/net/can/flexcan.c +7 -0
@@ -1192,6 +1200,13 @@ static void flexcan_set_bittiming_cbt(const struct net_device *dev)
        if (priv->can.ctrlmode & CAN_CTRLMODE_FD) {
                u32 reg_fdcbt;
 
+               reg_fdcbt = priv->read(&regs->fdcbt);
+               reg_fdcbt &= ~(FIELD_PREP(FLEXCAN_FDCBT_FPRESDIV_MASK, 0x3ff) |
+                       FIELD_PREP(FLEXCAN_FDCBT_FRJW_MASK, 0x7) |
+                       FIELD_PREP(FLEXCAN_FDCBT_FPROPSEG_MASK, 0x1f) |
+                       FIELD_PREP(FLEXCAN_FDCBT_FPSEG1_MASK, 0x7) |
+                       FIELD_PREP(FLEXCAN_FDCBT_FPSEG2_MASK, 0x7));
+

Okay, I'll add this, as the fdcbt contains some reserved bits...Let's preserve them.

I've changed the setting of reg_fdcbt like this to make sense:

drivers/net/can/flexcan.c static void flexcan_set_bittiming_cbt(const struct net_device *dev) · line 1210

Quoted 2 lines
drivers/net/can/flexcan.c +1 -1
-               reg_fdcbt = FIELD_PREP(FLEXCAN_FDCBT_FPRESDIV_MASK, dbt->brp - 1) |
+               reg_fdcbt |= FIELD_PREP(FLEXCAN_FDCBT_FPRESDIV_MASK, dbt->brp - 1) |

thanks,
Marc

Signature · 4 lines
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 |
#9 lore raw

RE: [PATCH linux-can-next/flexcan] can: flexcan: fix TDC feature

Quoted 14 lines

-----Original Message-----
From: Marc Kleine-Budde <[email protected]>
Sent: 2020年9月16日 6:16
To: Joakim Zhang <[email protected]>; Michael Walle <[email protected]>
Cc: [email protected]; dl-linux-imx <[email protected]>; [email protected]
Subject: Re: [PATCH linux-can-next/flexcan] can: flexcan: fix TDC feature

Quoted 3 lines · Joakim Zhang

I have also noticed this difference, although this could not break function, but IMO, using priv->can.ctrlmode should be better.

[...]

Quoted 17 lines

drivers/net/can/flexcan.c static void flexcan_set_bittiming_cbt(const

Quoted 4 lines

2) Clean timing register.

drivers/net/can/flexcan.c +0 -0
@@ -1167,6 +1167,14 @@ static void flexcan_set_bittiming_cbt(const

struct net_device *dev)

drivers/net/can/flexcan.c static void flexcan_set_bittiming_cbt(const struct net_device *dev) · line 1177

Quoted 11 lines
drivers/net/can/flexcan.c +8 -0
        struct flexcan_regs __iomem *regs = priv->regs;
        u32 reg_cbt, reg_fdctrl;
 
+       reg_cbt = priv->read(&regs->cbt);
+       reg_cbt &= ~(FLEXCAN_CBT_BTF |
+               FIELD_PREP(FLEXCAN_CBT_EPRESDIV_MASK, 0x3ff) |
+               FIELD_PREP(FLEXCAN_CBT_ERJW_MASK, 0x1f) |
+               FIELD_PREP(FLEXCAN_CBT_EPROPSEG_MASK, 0x3f) |
+               FIELD_PREP(FLEXCAN_CBT_EPSEG1_MASK, 0x1f) |
+               FIELD_PREP(FLEXCAN_CBT_EPSEG2_MASK, 0x1f));
+
Quoted 4 lines

Why is this needed? The "reg_cbt &=" sets reg_cbt basically to 0, as the fields and the BTF occupy all 32bit.

The only thing that's left over is the read()....

Yes, need not, I have not noticed it has occupy the whole 32bit.

There is a small improve patch to balance the usage_count if register flexcandev failed. Could you pick up it by the way this time?
https://www.spinics.net/lists/linux-can/msg03052.html

Best Regards,
Joakim Zhang

#10 lore raw

Re: [PATCH linux-can-next/flexcan] can: flexcan: fix TDC feature

In reply to Michael Walle
Quoted 6 lines · Michael Walle

Hi Marc,

Quoted 3 lines

I've cleaned up the patches a bit, can you test this branch:

https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git/log/?h=flexcan

Quoted 7 lines

This is working, but as Joakim already said, CAN-FD ISO mode is missing. It defaults to non-ISO mode, which is even worse, IMHO.

But I've also noticed a difference between the original patch and the one in that branch. When FD mode is enabled the original patch checks the priv->can.controlmode [1], the patch in the branch looks at priv->can.ctrlmode_supported instead [2], is that correct?

Nope, I've corrected this.

thanks,
Marc

Signature · 4 lines
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 |
#11 lore raw

RE: [PATCH linux-can-next/flexcan] can: flexcan: fix TDC feature

In reply to Marc Kleine-Budde
Quoted 32 lines

-----Original Message-----
From: Marc Kleine-Budde <[email protected]>
Sent: 2020年6月25日 20:57
To: Michael Walle <[email protected]>; Joakim Zhang <[email protected]>
Cc: [email protected]; dl-linux-imx <[email protected]>; [email protected]
Subject: Re: [PATCH linux-can-next/flexcan] can: flexcan: fix TDC feature

Quoted 13 lines · Michael Walle

Am 2020-06-02 12:15, schrieb Michael Walle:

Quoted 12 lines

Hi Marc,

Am 2020-04-16 11:41, schrieb Joakim Zhang:

Quoted 8 lines

Hi Marc,

How about FlexCAN FD patch set, it is pending for a long time. Many work would base on it, we are happy to see it in upstream mainline ASAP.

Michael Walle also gives out the test-by tag:

Quoted 7 lines
Quoted 2 lines

There seems to be no activity for months here. Any reason for that? Is there anything we can do to speed things up?

ping.. There are no replies or anything. Sorry but this is really annoying and frustrating.

Marc, is there anything wrong with the flexcan patches?

Quoted 8 lines

I've cleaned up the patches a bit, can you test this branch:

https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kern
el.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Fmkl%2Flinux-can-next.git%2 Flog%2F%3Fh%3Dflexcan&amp;data=02%7C01%7Cqiangqing.zhang%40nxp.co m%7Cddbe9019fae84641164508d819073129%7C686ea1d3bc2b4c6fa92cd99c 5c301635%7C0%7C0%7C637286865961564061&amp;sdata=Bm0uynxueF%2F WpECT8ayfqQxh%2FMYnFCLixvZLvSgUgI4%3D&amp;reserved=0

Hi Marc,

Thank you very much for your effort to clean up the code. I have test the patch set, it can work fine at my side.

But, a patch may be ignored, could you help add back it? Or you are unsatisfied with it, I can improve it according to your opinion.

commit d6ad5cc96229e28e4f2f0960277102ee142577ed

Author: Joakim Zhang <[email protected]>
Date:   Fri Jul 12 08:02:51 2019 +0000

can: flexcan: add ISO CAN FD feature support

ISO CAN FD is introduced to increase the failture detection capability than non-ISO CAN FD. The non-ISO CAN FD is still supported by FlexCAN so that it can be used mainly during an intermediate phase, for evaluation and development purposes.

Therefore, it is strongly recommended to configure FlexCAN to the ISO CAN FD protocol by setting the ISOCANFDEN field in the CTRL2 register.

NOTE: If you only set "fd on", driver will use ISO FD mode by default. You should set "fd-non-iso on" after setting "fd on" if you want to use NON ISO FD mode.

And, if it is okay for you, below patch could you also pick up?
can: flexcan: disable runtime PM if register flexcandev failed : https://www.spinics.net/lists/linux-can/msg03146.html

Best Regards,
Joakim Zhang

Quoted 12 lines

Marc

--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux |
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.p
engutronix.de%2F&amp;data=02%7C01%7Cqiangqing.zhang%40nxp.com%7Cd dbe9019fae84641164508d819073129%7C686ea1d3bc2b4c6fa92cd99c5c30163 5%7C0%7C0%7C637286865961564061&amp;sdata=U3OQykqsSE35Az9CVznq Ck1rl3Hc6UvERaPuh%2BVjHiw%3D&amp;reserved=0 |

Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
#12 lore raw

Re: [PATCH linux-can-next/flexcan] can: flexcan: fix TDC feature

In reply to Marc Kleine-Budde

Am 2020-06-25 14:56, schrieb Marc Kleine-Budde:

Quoted 17 lines · Michael Walle
Quoted 16 lines

Am 2020-06-02 12:15, schrieb Michael Walle:

Quoted 14 lines

Hi Marc,

Am 2020-04-16 11:41, schrieb Joakim Zhang:

Quoted 8 lines

Hi Marc,

How about FlexCAN FD patch set, it is pending for a long time. Many work would base on it, we are happy to see it in upstream mainline ASAP.

Michael Walle also gives out the test-by tag:

There seems to be no activity for months here. Any reason for that? Is there anything we can do to speed things up?

Quoted 8 lines
Quoted 4 lines

ping.. There are no replies or anything. Sorry but this is really annoying and frustrating.

Marc, is there anything wrong with the flexcan patches?

I've cleaned up the patches a bit, can you test this branch:

https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git/log/?h=flexcan

Ping. Could we please try to get this into next soon?

See also
https://lore.kernel.org/netdev/[email protected]/

-michael

#13 lore raw

Re: [PATCH linux-can-next/flexcan] can: flexcan: fix TDC feature

Hi Marc,

Am 2020-07-23 23:09, schrieb Michael Walle:

Quoted 23 lines

Am 2020-06-25 14:56, schrieb Marc Kleine-Budde:

Quoted 22 lines · Michael Walle
Quoted 20 lines

Am 2020-06-02 12:15, schrieb Michael Walle:

Quoted 9 lines

Hi Marc,

Am 2020-04-16 11:41, schrieb Joakim Zhang:

Quoted 6 lines

Hi Marc,

How about FlexCAN FD patch set, it is pending for a long time. Many work would base on it, we are happy to see it in upstream mainline ASAP.

Quoted 5 lines
Quoted 2 lines

Michael Walle also gives out the test-by tag:

There seems to be no activity for months here. Any reason for that? Is there anything we can do to speed things up?

ping.. There are no replies or anything. Sorry but this is really annoying and frustrating.

Marc, is there anything wrong with the flexcan patches?

Quoted 8 lines
Quoted 3 lines

I've cleaned up the patches a bit, can you test this branch:

https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git/log/?h=flexcan

Ping. Could we please try to get this into next soon?

See also
https://lore.kernel.org/netdev/[email protected]/

Ping, another 2.5 months without any activity on this :(

-michael