linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] can: flexcan: proposed fixes for v3.12
@ 2013-10-07 14:25 Marc Kleine-Budde
  2013-10-07 14:25 ` [PATCH v2 1/2] can: flexcan: flexcan_chip_start: fix regression, mark one MB for TX and abort pending TX Marc Kleine-Budde
  2013-10-07 14:25 ` [PATCH v2 2/2] can: flexcan: fix mx28 detection by rearanging OF match table Marc Kleine-Budde
  0 siblings, 2 replies; 3+ messages in thread
From: Marc Kleine-Budde @ 2013-10-07 14:25 UTC (permalink / raw)
  To: linux-can; +Cc: kernel, LW

Hello,

while hacking on a new feature on the flexcan driver I found two problems:

In my last patch on the flexcan dirver I removed the loop from
flexcan_chip_start(), this causes pending TX messages not beeing aborted on
device resart. Lothar, can you please test this patch on mx6.

The second patch fixes the problem, that a DT probed mx28 flexcan core is
detected as p1010. This activaes a workaround in the driver which is not
needed, the bus error interrupt is always active.

Please test, both patches apply to current net/master, latest v3.12-rcX should
work, too.

regards,
Marc



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

* [PATCH v2 1/2] can: flexcan: flexcan_chip_start: fix regression, mark one MB for TX and abort pending TX
  2013-10-07 14:25 [PATCH v2 1/2] can: flexcan: proposed fixes for v3.12 Marc Kleine-Budde
@ 2013-10-07 14:25 ` Marc Kleine-Budde
  2013-10-07 14:25 ` [PATCH v2 2/2] can: flexcan: fix mx28 detection by rearanging OF match table Marc Kleine-Budde
  1 sibling, 0 replies; 3+ messages in thread
From: Marc Kleine-Budde @ 2013-10-07 14:25 UTC (permalink / raw)
  To: linux-can; +Cc: kernel, LW, Marc Kleine-Budde

In patch

    0d1862e can: flexcan: fix flexcan_chip_start() on imx6

the loop in flexcan_chip_start() that iterates over all mailboxes after the
soft reset of the CAN core was removed. This loop put all mailboxes (even the
ones marked as reserved 1...7) into EMPTY/INACTIVE mode. On mailboxes 8...63,
this aborts any pending TX messages.

After a cold boot there is random garbage in the mailboxes, which leads to
spontaneous transmit of CAN frames during first activation. Further if the
interface was disabled with a pending message (usually due to an error
condition on the CAN bus), this message is retransmitted after enabling the
interface again.

This patch fixes the regression by:
1) Limiting the maximum number of used mailboxes to 8, 0...7 are used by the RX
FIFO, 8 is used by TX.
2) Marking the TX mailbox as EMPTY/INACTIVE, so that any pending TX of that
mailbox is aborted.

Cc: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
changes since v1:
- limit maximal mailbox number used by hardware to 8 (== TX mailbox)

 drivers/net/can/flexcan.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 3f21142..f028c5d 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -62,7 +62,7 @@
 #define FLEXCAN_MCR_BCC			BIT(16)
 #define FLEXCAN_MCR_LPRIO_EN		BIT(13)
 #define FLEXCAN_MCR_AEN			BIT(12)
-#define FLEXCAN_MCR_MAXMB(x)		((x) & 0xf)
+#define FLEXCAN_MCR_MAXMB(x)		((x) & 0x1f)
 #define FLEXCAN_MCR_IDAM_A		(0 << 8)
 #define FLEXCAN_MCR_IDAM_B		(1 << 8)
 #define FLEXCAN_MCR_IDAM_C		(2 << 8)
@@ -735,9 +735,11 @@ static int flexcan_chip_start(struct net_device *dev)
 	 *
 	 */
 	reg_mcr = flexcan_read(&regs->mcr);
+	reg_mcr &= ~FLEXCAN_MCR_MAXMB(0xff);
 	reg_mcr |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_FEN | FLEXCAN_MCR_HALT |
 		FLEXCAN_MCR_SUPV | FLEXCAN_MCR_WRN_EN |
-		FLEXCAN_MCR_IDAM_C | FLEXCAN_MCR_SRX_DIS;
+		FLEXCAN_MCR_IDAM_C | FLEXCAN_MCR_SRX_DIS |
+		FLEXCAN_MCR_MAXMB(FLEXCAN_TX_BUF_ID);
 	netdev_dbg(dev, "%s: writing mcr=0x%08x", __func__, reg_mcr);
 	flexcan_write(reg_mcr, &regs->mcr);
 
@@ -771,6 +773,10 @@ static int flexcan_chip_start(struct net_device *dev)
 	netdev_dbg(dev, "%s: writing ctrl=0x%08x", __func__, reg_ctrl);
 	flexcan_write(reg_ctrl, &regs->ctrl);
 
+	/* Abort any pending TX, mark Mailbox as INACTIVE */
+	flexcan_write(FLEXCAN_MB_CNT_CODE(0x4),
+		      &regs->cantxfg[FLEXCAN_TX_BUF_ID].can_ctrl);
+
 	/* acceptance mask/acceptance code (accept everything) */
 	flexcan_write(0x0, &regs->rxgmask);
 	flexcan_write(0x0, &regs->rx14mask);
-- 
1.8.4.rc3


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

* [PATCH v2 2/2] can: flexcan: fix mx28 detection by rearanging OF match table
  2013-10-07 14:25 [PATCH v2 1/2] can: flexcan: proposed fixes for v3.12 Marc Kleine-Budde
  2013-10-07 14:25 ` [PATCH v2 1/2] can: flexcan: flexcan_chip_start: fix regression, mark one MB for TX and abort pending TX Marc Kleine-Budde
@ 2013-10-07 14:25 ` Marc Kleine-Budde
  1 sibling, 0 replies; 3+ messages in thread
From: Marc Kleine-Budde @ 2013-10-07 14:25 UTC (permalink / raw)
  To: linux-can; +Cc: kernel, LW, Marc Kleine-Budde

The current implemetation of of_match_device() relies that the of_device_id
table in the driver is sorted from most specific to least specific compatible.

Without this patch the mx28 is detected as the less specific p1010. This leads
to a p1010 specific workaround is activated on the mx28, which is not needed.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/flexcan.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index f028c5d..8f5ce74 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -985,9 +985,9 @@ static void unregister_flexcandev(struct net_device *dev)
 }
 
 static const struct of_device_id flexcan_of_match[] = {
-	{ .compatible = "fsl,p1010-flexcan", .data = &fsl_p1010_devtype_data, },
-	{ .compatible = "fsl,imx28-flexcan", .data = &fsl_imx28_devtype_data, },
 	{ .compatible = "fsl,imx6q-flexcan", .data = &fsl_imx6q_devtype_data, },
+	{ .compatible = "fsl,imx28-flexcan", .data = &fsl_imx28_devtype_data, },
+	{ .compatible = "fsl,p1010-flexcan", .data = &fsl_p1010_devtype_data, },
 	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, flexcan_of_match);
-- 
1.8.4.rc3


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

end of thread, other threads:[~2013-10-07 14:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-07 14:25 [PATCH v2 1/2] can: flexcan: proposed fixes for v3.12 Marc Kleine-Budde
2013-10-07 14:25 ` [PATCH v2 1/2] can: flexcan: flexcan_chip_start: fix regression, mark one MB for TX and abort pending TX Marc Kleine-Budde
2013-10-07 14:25 ` [PATCH v2 2/2] can: flexcan: fix mx28 detection by rearanging OF match table Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).