All of lore.kernel.org
 help / color / mirror / Atom feed
* linux-can/testing: Request for testing
@ 2019-10-10 12:17 Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 01/29] can: dev: add missing of_node_put() after calling of_get_child_by_name() Marc Kleine-Budde
                   ` (28 more replies)
  0 siblings, 29 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck

Hello,

this patch series is the upcoming pull request for net/master.

One of the biggest changes is the cleanup of the error handling in the
rx-offload infrastructure. If queueing fails the skbs are now properly
freed.

Please test.

regards,
Marc

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

* [PATCH 01/29] can: dev: add missing of_node_put() after calling of_get_child_by_name()
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 02/29] can: gs_usb: gs_can_open(): prevent memory leak Marc Kleine-Budde
                   ` (27 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Wen Yang, Franklin S Cooper Jr, linux-stable, Marc Kleine-Budde

From: Wen Yang <wenyang@linux.alibaba.com>

of_node_put() needs to be called when the device node which is got
from of_get_child_by_name() finished using.

Fixes: 2290aefa2e90 ("can: dev: Add support for limiting configured bitrate")
Cc: Franklin S Cooper Jr <fcooper@ti.com>
Signed-off-by: Wen Yang <wenyang@linux.alibaba.com>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/dev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index ac86be52b461..1c88c361938c 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -848,6 +848,7 @@ void of_can_transceiver(struct net_device *dev)
 		return;
 
 	ret = of_property_read_u32(dn, "max-bitrate", &priv->bitrate_max);
+	of_node_put(dn);
 	if ((ret && ret != -EINVAL) || (!ret && !priv->bitrate_max))
 		netdev_warn(dev, "Invalid value for transceiver max bitrate. Ignoring bitrate limit.\n");
 }
-- 
2.23.0

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

* [PATCH 02/29] can: gs_usb: gs_can_open(): prevent memory leak
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 01/29] can: dev: add missing of_node_put() after calling of_get_child_by_name() Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 03/29] can: mcba_usb: fix use-after-free on disconnect Marc Kleine-Budde
                   ` (26 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Navid Emamdoost, linux-stable, Marc Kleine-Budde

From: Navid Emamdoost <navid.emamdoost@gmail.com>

In gs_can_open() if usb_submit_urb() fails the allocated urb should be
released.

Fixes: d08e973a77d1 ("can: gs_usb: Added support for the GS_USB CAN devices")
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/gs_usb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c
index bd6eb9967630..2f74f6704c12 100644
--- a/drivers/net/can/usb/gs_usb.c
+++ b/drivers/net/can/usb/gs_usb.c
@@ -623,6 +623,7 @@ static int gs_can_open(struct net_device *netdev)
 					   rc);
 
 				usb_unanchor_urb(urb);
+				usb_free_urb(urb);
 				break;
 			}
 
-- 
2.23.0

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

* [PATCH 03/29] can: mcba_usb: fix use-after-free on disconnect
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 01/29] can: dev: add missing of_node_put() after calling of_get_child_by_name() Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 02/29] can: gs_usb: gs_can_open(): prevent memory leak Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 04/29] can: usb_8dev: " Marc Kleine-Budde
                   ` (25 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Johan Hovold, stable, Remigiusz Kołłątaj,
	syzbot+e29b17e5042bbc56fae9, Marc Kleine-Budde

From: Johan Hovold <johan@kernel.org>

The driver was accessing its driver data after having freed it.

Fixes: 51f3baad7de9 ("can: mcba_usb: Add support for Microchip CAN BUS Analyzer")
Cc: stable <stable@vger.kernel.org>     # 4.12
Cc: Remigiusz Kołłątaj <remigiusz.kollataj@mobica.com>
Reported-by: syzbot+e29b17e5042bbc56fae9@syzkaller.appspotmail.com
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/mcba_usb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/can/usb/mcba_usb.c b/drivers/net/can/usb/mcba_usb.c
index 19a702ac49e4..21faa2ec4632 100644
--- a/drivers/net/can/usb/mcba_usb.c
+++ b/drivers/net/can/usb/mcba_usb.c
@@ -876,9 +876,8 @@ static void mcba_usb_disconnect(struct usb_interface *intf)
 	netdev_info(priv->netdev, "device disconnected\n");
 
 	unregister_candev(priv->netdev);
-	free_candev(priv->netdev);
-
 	mcba_urb_unlink(priv);
+	free_candev(priv->netdev);
 }
 
 static struct usb_driver mcba_usb_driver = {
-- 
2.23.0

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

* [PATCH 04/29] can: usb_8dev: fix use-after-free on disconnect
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (2 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 03/29] can: mcba_usb: fix use-after-free on disconnect Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 05/29] can: flexcan: disable completely the ECC mechanism Marc Kleine-Budde
                   ` (24 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Johan Hovold, stable, Bernd Krumboeck, Wolfgang Grandegger,
	Marc Kleine-Budde

From: Johan Hovold <johan@kernel.org>

The driver was accessing its driver data after having freed it.

Fixes: 0024d8ad1639 ("can: usb_8dev: Add support for USB2CAN interface from 8 devices")
Cc: stable <stable@vger.kernel.org>     # 3.9
Cc: Bernd Krumboeck <b.krumboeck@gmail.com>
Cc: Wolfgang Grandegger <wg@grandegger.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/usb_8dev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/can/usb/usb_8dev.c b/drivers/net/can/usb/usb_8dev.c
index d596a2ad7f78..8fa224b28218 100644
--- a/drivers/net/can/usb/usb_8dev.c
+++ b/drivers/net/can/usb/usb_8dev.c
@@ -996,9 +996,8 @@ static void usb_8dev_disconnect(struct usb_interface *intf)
 		netdev_info(priv->netdev, "device disconnected\n");
 
 		unregister_netdev(priv->netdev);
-		free_candev(priv->netdev);
-
 		unlink_all_urbs(priv);
+		free_candev(priv->netdev);
 	}
 
 }
-- 
2.23.0

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

* [PATCH 05/29] can: flexcan: disable completely the ECC mechanism
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (3 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 04/29] can: usb_8dev: " Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 06/29] can: peak_usb: fix a potential out-of-sync while decoding packets Marc Kleine-Budde
                   ` (23 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Joakim Zhang, linux-stable, Marc Kleine-Budde

From: Joakim Zhang <qiangqing.zhang@nxp.com>

The ECC (memory error detection and correction) mechanism can be
activated or not, controlled by the ECCDIS bit in CAN_MECR. When
disabled, updates on indications and reporting registers are stopped.
So if want to disable ECC completely, had better assert ECCDIS bit, not
just mask the related interrupts.

Fixes: cdce844865be ("can: flexcan: add vf610 support for FlexCAN")
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/flexcan.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index dc5695dffc2e..1cd5179cb876 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -1188,6 +1188,7 @@ static int flexcan_chip_start(struct net_device *dev)
 		reg_mecr = priv->read(&regs->mecr);
 		reg_mecr &= ~FLEXCAN_MECR_ECRWRDIS;
 		priv->write(reg_mecr, &regs->mecr);
+		reg_mecr |= FLEXCAN_MECR_ECCDIS;
 		reg_mecr &= ~(FLEXCAN_MECR_NCEFAFRZ | FLEXCAN_MECR_HANCEI_MSK |
 			      FLEXCAN_MECR_FANCEI_MSK);
 		priv->write(reg_mecr, &regs->mecr);
-- 
2.23.0

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

* [PATCH 06/29] can: peak_usb: fix a potential out-of-sync while decoding packets
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (4 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 05/29] can: flexcan: disable completely the ECC mechanism Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 07/29] can: peak_usb: report bus recovery as well Marc Kleine-Budde
                   ` (22 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Stephane Grosjean, linux-stable, Marc Kleine-Budde

From: Stephane Grosjean <s.grosjean@peak-system.com>

When decoding a buffer received from PCAN-USB, the first timestamp read in
a packet is a 16-bit coded time base, and the next ones are an 8-bit
offset to this base, regardless of the type of packet read.

This patch corrects a potential loss of synchronization by using a
timestamp index read from the buffer, rather than an index of received
data packets, to determine on the sizeof the timestamp to be read from the
packet being decoded.

Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
Fixes: 46be265d3388 ("can: usb: PEAK-System Technik PCAN-USB specific part")
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/peak_usb/pcan_usb.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/net/can/usb/peak_usb/pcan_usb.c b/drivers/net/can/usb/peak_usb/pcan_usb.c
index 617da295b6c1..5a66c9f53aae 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb.c
@@ -100,7 +100,7 @@ struct pcan_usb_msg_context {
 	u8 *end;
 	u8 rec_cnt;
 	u8 rec_idx;
-	u8 rec_data_idx;
+	u8 rec_ts_idx;
 	struct net_device *netdev;
 	struct pcan_usb *pdev;
 };
@@ -547,10 +547,15 @@ static int pcan_usb_decode_status(struct pcan_usb_msg_context *mc,
 	mc->ptr += PCAN_USB_CMD_ARGS;
 
 	if (status_len & PCAN_USB_STATUSLEN_TIMESTAMP) {
-		int err = pcan_usb_decode_ts(mc, !mc->rec_idx);
+		int err = pcan_usb_decode_ts(mc, !mc->rec_ts_idx);
 
 		if (err)
 			return err;
+
+		/* Next packet in the buffer will have a timestamp on a single
+		 * byte
+		 */
+		mc->rec_ts_idx++;
 	}
 
 	switch (f) {
@@ -632,10 +637,13 @@ static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len)
 
 	cf->can_dlc = get_can_dlc(rec_len);
 
-	/* first data packet timestamp is a word */
-	if (pcan_usb_decode_ts(mc, !mc->rec_data_idx))
+	/* Only first packet timestamp is a word */
+	if (pcan_usb_decode_ts(mc, !mc->rec_ts_idx))
 		goto decode_failed;
 
+	/* Next packet in the buffer will have a timestamp on a single byte */
+	mc->rec_ts_idx++;
+
 	/* read data */
 	memset(cf->data, 0x0, sizeof(cf->data));
 	if (status_len & PCAN_USB_STATUSLEN_RTR) {
@@ -688,7 +696,6 @@ static int pcan_usb_decode_msg(struct peak_usb_device *dev, u8 *ibuf, u32 lbuf)
 		/* handle normal can frames here */
 		} else {
 			err = pcan_usb_decode_data(&mc, sl);
-			mc.rec_data_idx++;
 		}
 	}
 
-- 
2.23.0

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

* [PATCH 07/29] can: peak_usb: report bus recovery as well
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (5 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 06/29] can: peak_usb: fix a potential out-of-sync while decoding packets Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 08/29] can: c_can: c_can_poll(): only read status register after status IRQ Marc Kleine-Budde
                   ` (21 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Stephane Grosjean, Marc Kleine-Budde

From: Jeroen Hofstee <jhofstee@victronenergy.com>

While the state changes are reported when the error counters increase
and decrease, there is no event when the bus recovers and the error
counters decrease again. So add those as well.

Change the state going downward to be ERROR_PASSIVE -> ERROR_WARNING ->
ERROR_ACTIVE instead of directly to ERROR_ACTIVE again.

Signed-off-by: Jeroen Hofstee <jhofstee@victronenergy.com>
Cc: Stephane Grosjean <s.grosjean@peak-system.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/peak_usb/pcan_usb.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/net/can/usb/peak_usb/pcan_usb.c b/drivers/net/can/usb/peak_usb/pcan_usb.c
index 5a66c9f53aae..d2539c95adb6 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb.c
@@ -436,8 +436,8 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,
 		}
 		if ((n & PCAN_USB_ERROR_BUS_LIGHT) == 0) {
 			/* no error (back to active state) */
-			mc->pdev->dev.can.state = CAN_STATE_ERROR_ACTIVE;
-			return 0;
+			new_state = CAN_STATE_ERROR_ACTIVE;
+			break;
 		}
 		break;
 
@@ -460,9 +460,9 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,
 		}
 
 		if ((n & PCAN_USB_ERROR_BUS_HEAVY) == 0) {
-			/* no error (back to active state) */
-			mc->pdev->dev.can.state = CAN_STATE_ERROR_ACTIVE;
-			return 0;
+			/* no error (back to warning state) */
+			new_state = CAN_STATE_ERROR_WARNING;
+			break;
 		}
 		break;
 
@@ -501,6 +501,11 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,
 		mc->pdev->dev.can.can_stats.error_warning++;
 		break;
 
+	case CAN_STATE_ERROR_ACTIVE:
+		cf->can_id |= CAN_ERR_CRTL;
+		cf->data[1] = CAN_ERR_CRTL_ACTIVE;
+		break;
+
 	default:
 		/* CAN_STATE_MAX (trick to handle other errors) */
 		cf->can_id |= CAN_ERR_CRTL;
-- 
2.23.0

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

* [PATCH 08/29] can: c_can: c_can_poll(): only read status register after status IRQ
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (6 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 07/29] can: peak_usb: report bus recovery as well Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 09/29] can: c_can: D_CAN: c_can_chip_config(): perform a sofware reset on open Marc Kleine-Budde
                   ` (20 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Wolfgang Grandegger, Joe Burmeister, linux-stable,
	Marc Kleine-Budde

From: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>

When the status register is read without the status IRQ pending, the
chip may not raise the interrupt line for an upcoming status interrupt
and the driver may miss a status interrupt.

It is critical that the BUSOFF status interrupt is forwarded to the
higher layers, since no more interrupts will follow without
intervention.

Thanks to Wolfgang and Joe for bringing up the first idea.

Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
Cc: Wolfgang Grandegger <wg@grandegger.com>
Cc: Joe Burmeister <joe.burmeister@devtank.co.uk>
Fixes: fa39b54ccf28 ("can: c_can: Get rid of pointless interrupts")
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/c_can/c_can.c | 25 ++++++++++++++++++++-----
 drivers/net/can/c_can/c_can.h |  1 +
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
index 606b7d8ffe13..9b61bfbea6cd 100644
--- a/drivers/net/can/c_can/c_can.c
+++ b/drivers/net/can/c_can/c_can.c
@@ -97,6 +97,9 @@
 #define BTR_TSEG2_SHIFT		12
 #define BTR_TSEG2_MASK		(0x7 << BTR_TSEG2_SHIFT)
 
+/* interrupt register */
+#define INT_STS_PENDING		0x8000
+
 /* brp extension register */
 #define BRP_EXT_BRPE_MASK	0x0f
 #define BRP_EXT_BRPE_SHIFT	0
@@ -1029,10 +1032,16 @@ static int c_can_poll(struct napi_struct *napi, int quota)
 	u16 curr, last = priv->last_status;
 	int work_done = 0;
 
-	priv->last_status = curr = priv->read_reg(priv, C_CAN_STS_REG);
-	/* Ack status on C_CAN. D_CAN is self clearing */
-	if (priv->type != BOSCH_D_CAN)
-		priv->write_reg(priv, C_CAN_STS_REG, LEC_UNUSED);
+	/* Only read the status register if a status interrupt was pending */
+	if (atomic_xchg(&priv->sie_pending, 0)) {
+		priv->last_status = curr = priv->read_reg(priv, C_CAN_STS_REG);
+		/* Ack status on C_CAN. D_CAN is self clearing */
+		if (priv->type != BOSCH_D_CAN)
+			priv->write_reg(priv, C_CAN_STS_REG, LEC_UNUSED);
+	} else {
+		/* no change detected ... */
+		curr = last;
+	}
 
 	/* handle state changes */
 	if ((curr & STATUS_EWARN) && (!(last & STATUS_EWARN))) {
@@ -1083,10 +1092,16 @@ static irqreturn_t c_can_isr(int irq, void *dev_id)
 {
 	struct net_device *dev = (struct net_device *)dev_id;
 	struct c_can_priv *priv = netdev_priv(dev);
+	int reg_int;
 
-	if (!priv->read_reg(priv, C_CAN_INT_REG))
+	reg_int = priv->read_reg(priv, C_CAN_INT_REG);
+	if (!reg_int)
 		return IRQ_NONE;
 
+	/* save for later use */
+	if (reg_int & INT_STS_PENDING)
+		atomic_set(&priv->sie_pending, 1);
+
 	/* disable all interrupts and schedule the NAPI */
 	c_can_irq_control(priv, false);
 	napi_schedule(&priv->napi);
diff --git a/drivers/net/can/c_can/c_can.h b/drivers/net/can/c_can/c_can.h
index 8acdc7fa4792..d5567a7c1c6d 100644
--- a/drivers/net/can/c_can/c_can.h
+++ b/drivers/net/can/c_can/c_can.h
@@ -198,6 +198,7 @@ struct c_can_priv {
 	struct net_device *dev;
 	struct device *device;
 	atomic_t tx_active;
+	atomic_t sie_pending;
 	unsigned long tx_dir;
 	int last_status;
 	u16 (*read_reg) (const struct c_can_priv *priv, enum reg index);
-- 
2.23.0

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

* [PATCH 09/29] can: c_can: D_CAN: c_can_chip_config(): perform a sofware reset on open
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (7 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 08/29] can: c_can: c_can_poll(): only read status register after status IRQ Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 10/29] can: c_can: C_CAN: add bus recovery events Marc Kleine-Budde
                   ` (19 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Marc Kleine-Budde

From: Jeroen Hofstee <jhofstee@victronenergy.com>

When the CAN interface is closed it the hardwre is put in power down
mode, but does not reset the error counters / state. Reset the D_CAN on
open, so the reported state and the actual state match.

According to [1], the C_CAN module doesn't have the software reset.

[1] http://www.bosch-semiconductors.com/media/ip_modules/pdf_2/c_can_fd8/users_manual_c_can_fd8_r210_1.pdf

Signed-off-by: Jeroen Hofstee <jhofstee@victronenergy.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/c_can/c_can.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
index 9b61bfbea6cd..24c6015f6c92 100644
--- a/drivers/net/can/c_can/c_can.c
+++ b/drivers/net/can/c_can/c_can.c
@@ -52,6 +52,7 @@
 #define CONTROL_EX_PDR		BIT(8)
 
 /* control register */
+#define CONTROL_SWR		BIT(15)
 #define CONTROL_TEST		BIT(7)
 #define CONTROL_CCE		BIT(6)
 #define CONTROL_DISABLE_AR	BIT(5)
@@ -572,6 +573,26 @@ static void c_can_configure_msg_objects(struct net_device *dev)
 				   IF_MCONT_RCV_EOB);
 }
 
+static int c_can_software_reset(struct net_device *dev)
+{
+	struct c_can_priv *priv = netdev_priv(dev);
+	int retry = 0;
+
+	if (priv->type != BOSCH_D_CAN)
+		return 0;
+
+	priv->write_reg(priv, C_CAN_CTRL_REG, CONTROL_SWR | CONTROL_INIT);
+	while (priv->read_reg(priv, C_CAN_CTRL_REG) & CONTROL_SWR) {
+		msleep(20);
+		if (retry++ > 100) {
+			netdev_err(dev, "CCTRL: software reset failed\n");
+			return -EIO;
+		}
+	}
+
+	return 0;
+}
+
 /*
  * Configure C_CAN chip:
  * - enable/disable auto-retransmission
@@ -581,6 +602,11 @@ static void c_can_configure_msg_objects(struct net_device *dev)
 static int c_can_chip_config(struct net_device *dev)
 {
 	struct c_can_priv *priv = netdev_priv(dev);
+	int err;
+
+	err = c_can_software_reset(dev);
+	if (err)
+		return err;
 
 	/* enable automatic retransmission */
 	priv->write_reg(priv, C_CAN_CTRL_REG, CONTROL_ENABLE_AR);
-- 
2.23.0

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

* [PATCH 10/29] can: c_can: C_CAN: add bus recovery events
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (8 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 09/29] can: c_can: D_CAN: c_can_chip_config(): perform a sofware reset on open Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 11/29] can: xilinx_can: Fix flags field initialization for axi can Marc Kleine-Budde
                   ` (18 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Marc Kleine-Budde

From: Jeroen Hofstee <jhofstee@victronenergy.com>

While the state is updated when the error counters increase and
decrease, there is no event when the bus recovers and the error counters
decrease again. So add that event as well.

Change the state going downward to be ERROR_PASSIVE -> ERROR_WARNING ->
ERROR_ACTIVE instead of directly to ERROR_ACTIVE again.

Signed-off-by: Jeroen Hofstee <jhofstee@victronenergy.com>
Acked-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
Tested-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/c_can/c_can.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
index 24c6015f6c92..8e9f5620c9a2 100644
--- a/drivers/net/can/c_can/c_can.c
+++ b/drivers/net/can/c_can/c_can.c
@@ -915,6 +915,9 @@ static int c_can_handle_state_change(struct net_device *dev,
 	struct can_berr_counter bec;
 
 	switch (error_type) {
+	case C_CAN_NO_ERROR:
+		priv->can.state = CAN_STATE_ERROR_ACTIVE;
+		break;
 	case C_CAN_ERROR_WARNING:
 		/* error warning state */
 		priv->can.can_stats.error_warning++;
@@ -945,6 +948,13 @@ static int c_can_handle_state_change(struct net_device *dev,
 				ERR_CNT_RP_SHIFT;
 
 	switch (error_type) {
+	case C_CAN_NO_ERROR:
+		/* error warning state */
+		cf->can_id |= CAN_ERR_CRTL;
+		cf->data[1] = CAN_ERR_CRTL_ACTIVE;
+		cf->data[6] = bec.txerr;
+		cf->data[7] = bec.rxerr;
+		break;
 	case C_CAN_ERROR_WARNING:
 		/* error warning state */
 		cf->can_id |= CAN_ERR_CRTL;
@@ -1089,11 +1099,17 @@ static int c_can_poll(struct napi_struct *napi, int quota)
 	/* handle bus recovery events */
 	if ((!(curr & STATUS_BOFF)) && (last & STATUS_BOFF)) {
 		netdev_dbg(dev, "left bus off state\n");
-		priv->can.state = CAN_STATE_ERROR_ACTIVE;
+		work_done += c_can_handle_state_change(dev, C_CAN_ERROR_PASSIVE);
 	}
+
 	if ((!(curr & STATUS_EPASS)) && (last & STATUS_EPASS)) {
 		netdev_dbg(dev, "left error passive state\n");
-		priv->can.state = CAN_STATE_ERROR_ACTIVE;
+		work_done += c_can_handle_state_change(dev, C_CAN_ERROR_WARNING);
+	}
+
+	if ((!(curr & STATUS_EWARN)) && (last & STATUS_EWARN)) {
+		netdev_dbg(dev, "left error warning state\n");
+		work_done += c_can_handle_state_change(dev, C_CAN_NO_ERROR);
 	}
 
 	/* handle lec errors on the bus */
-- 
2.23.0

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

* [PATCH 11/29] can: xilinx_can: Fix flags field initialization for axi can
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (9 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 10/29] can: c_can: C_CAN: add bus recovery events Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 12/29] can: rx-offload: can_rx_offload_queue_sorted(): fix error handling, avoid skb mem leak Marc Kleine-Budde
                   ` (17 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Appana Durga Kedareswara rao, Anssi Hannula, Marc Kleine-Budde

From: Appana Durga Kedareswara rao <appana.durga.rao@xilinx.com>

AXI CANIP doesn't support tx fifo empty interrupt feature(TXFEMP),
update the flags filed in the driver for AXI CAN case accordingly.

Fixes: 3281b380ec9f ("can: xilinx_can: Fix flags field initialization for axi can and canps")
Reported-by: Anssi Hannula <anssi.hannula@bitwise.fi>
Signed-off-by: Appana Durga Kedareswara rao <appana.durga.rao@xilinx.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/xilinx_can.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c
index 911b34316c9d..7c482b2d78d2 100644
--- a/drivers/net/can/xilinx_can.c
+++ b/drivers/net/can/xilinx_can.c
@@ -1599,7 +1599,6 @@ static const struct xcan_devtype_data xcan_zynq_data = {
 
 static const struct xcan_devtype_data xcan_axi_data = {
 	.cantype = XAXI_CAN,
-	.flags = XCAN_FLAG_TXFEMP,
 	.bittiming_const = &xcan_bittiming_const,
 	.btr_ts2_shift = XCAN_BTR_TS2_SHIFT,
 	.btr_sjw_shift = XCAN_BTR_SJW_SHIFT,
-- 
2.23.0

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

* [PATCH 12/29] can: rx-offload: can_rx_offload_queue_sorted(): fix error handling, avoid skb mem leak
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (10 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 11/29] can: xilinx_can: Fix flags field initialization for axi can Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 13/29] can: rx-offload: can_rx_offload_queue_tail(): " Marc Kleine-Budde
                   ` (16 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Marc Kleine-Budde, linux-stable

If the rx-offload skb_queue is full can_rx_offload_queue_sorted() will
not queue the skb and return with an error.

None of the callers of this function, issue a kfree_skb() to free the
not queued skb. This results in a memory leak.

This patch fixes the problem by freeing the skb in case of a full queue.
The return value is adjusted to -ENOBUFS to better reflect the actual
problem.

The device stats handling is left to the callers, as this function
mightbe used in both the rx and tx path.

Fixes: 55059f2b7f86 ("can: rx-offload: introduce can_rx_offload_get_echo_skb() and can_rx_offload_queue_sorted() functions")
Cc: linux-stable <stable@vger.kernel.org>
Cc: Martin Hundebøll <martin@geanix.com>
Reported-by: Martin Hundebøll <martin@geanix.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/rx-offload.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/rx-offload.c b/drivers/net/can/rx-offload.c
index e6a668ee7730..663697439d1c 100644
--- a/drivers/net/can/rx-offload.c
+++ b/drivers/net/can/rx-offload.c
@@ -207,8 +207,10 @@ int can_rx_offload_queue_sorted(struct can_rx_offload *offload,
 	unsigned long flags;
 
 	if (skb_queue_len(&offload->skb_queue) >
-	    offload->skb_queue_len_max)
-		return -ENOMEM;
+	    offload->skb_queue_len_max) {
+		kfree_skb(skb);
+		return -ENOBUFS;
+	}
 
 	cb = can_rx_offload_get_cb(skb);
 	cb->timestamp = timestamp;
-- 
2.23.0

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

* [PATCH 13/29] can: rx-offload: can_rx_offload_queue_tail(): fix error handling, avoid skb mem leak
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (11 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 12/29] can: rx-offload: can_rx_offload_queue_sorted(): fix error handling, avoid skb mem leak Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 14/29] can: rx-offload: can_rx_offload_offload_one(): do not increase the skb_queue beyond skb_queue_len_max Marc Kleine-Budde
                   ` (15 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Marc Kleine-Budde

If the rx-offload skb_queue is full can_rx_offload_queue_tail() will not
queue the skb and return with an error.

This patch frees the skb in case of a full queue, which brings
can_rx_offload_queue_tail() in line with the
can_rx_offload_queue_sorted() function, which has been adjusted in the
previous patch.

The return value is adjusted to -ENOBUFS to better reflect the actual
problem.

The device stats handling is left to the caller.

Fixes: d254586c3453 ("can: rx-offload: Add support for HW fifo based irq offloading")
Reported-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/rx-offload.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/rx-offload.c b/drivers/net/can/rx-offload.c
index 663697439d1c..d1c863409945 100644
--- a/drivers/net/can/rx-offload.c
+++ b/drivers/net/can/rx-offload.c
@@ -252,8 +252,10 @@ int can_rx_offload_queue_tail(struct can_rx_offload *offload,
 			      struct sk_buff *skb)
 {
 	if (skb_queue_len(&offload->skb_queue) >
-	    offload->skb_queue_len_max)
-		return -ENOMEM;
+	    offload->skb_queue_len_max) {
+		kfree_skb(skb);
+		return -ENOBUFS;
+	}
 
 	skb_queue_tail(&offload->skb_queue, skb);
 	can_rx_offload_schedule(offload);
-- 
2.23.0

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

* [PATCH 14/29] can: rx-offload: can_rx_offload_offload_one(): do not increase the skb_queue beyond skb_queue_len_max
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (12 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 13/29] can: rx-offload: can_rx_offload_queue_tail(): " Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 15/29] can: rx-offload: can_rx_offload_offload_one(): increment rx_fifo_errors on queue overflow or OOM Marc Kleine-Budde
                   ` (14 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Marc Kleine-Budde

The skb_queue is a linked list, holding the skb to be processed in the
next NAPI call.

Without this patch, the queue length in can_rx_offload_offload_one() is
limited to skb_queue_len_max + 1. As the skb_queue is a linked list, no
array or other resources are accessed out-of-bound, however this
behaviour is counterintuitive.

This patch limits the rx-offload skb_queue length to skb_queue_len_max.

Fixes: d254586c3453 ("can: rx-offload: Add support for HW fifo based irq offloading")
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/rx-offload.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/rx-offload.c b/drivers/net/can/rx-offload.c
index d1c863409945..bdc27481b57f 100644
--- a/drivers/net/can/rx-offload.c
+++ b/drivers/net/can/rx-offload.c
@@ -115,7 +115,7 @@ static struct sk_buff *can_rx_offload_offload_one(struct can_rx_offload *offload
 	int ret;
 
 	/* If queue is full or skb not available, read to discard mailbox */
-	if (likely(skb_queue_len(&offload->skb_queue) <=
+	if (likely(skb_queue_len(&offload->skb_queue) <
 		   offload->skb_queue_len_max))
 		skb = alloc_can_skb(offload->dev, &cf);
 
-- 
2.23.0

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

* [PATCH 15/29] can: rx-offload: can_rx_offload_offload_one(): increment rx_fifo_errors on queue overflow or OOM
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (13 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 14/29] can: rx-offload: can_rx_offload_offload_one(): do not increase the skb_queue beyond skb_queue_len_max Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 16/29] can: rx-offload: can_rx_offload_offload_one(): use ERR_PTR() to propagate error value in case of errors Marc Kleine-Budde
                   ` (13 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Marc Kleine-Budde

If the rx-offload skb_queue is full or the skb allocation fails (due to OOM),
the mailbox contents is discarded.

This patch adds the incrementing of the rx_fifo_errors statistics counter.

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

diff --git a/drivers/net/can/rx-offload.c b/drivers/net/can/rx-offload.c
index bdc27481b57f..e224530a0630 100644
--- a/drivers/net/can/rx-offload.c
+++ b/drivers/net/can/rx-offload.c
@@ -125,8 +125,10 @@ static struct sk_buff *can_rx_offload_offload_one(struct can_rx_offload *offload
 
 		ret = offload->mailbox_read(offload, &cf_overflow,
 					    &timestamp, n);
-		if (ret)
+		if (ret) {
 			offload->dev->stats.rx_dropped++;
+			offload->dev->stats.rx_fifo_errors++;
+		}
 
 		return NULL;
 	}
-- 
2.23.0

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

* [PATCH 16/29] can: rx-offload: can_rx_offload_offload_one(): use ERR_PTR() to propagate error value in case of errors
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (14 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 15/29] can: rx-offload: can_rx_offload_offload_one(): increment rx_fifo_errors on queue overflow or OOM Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 17/29] can: rx-offload: can_rx_offload_irq_offload_timestamp(): continue on error Marc Kleine-Budde
                   ` (12 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Marc Kleine-Budde

Before this patch can_rx_offload_offload_one() returns a pointer to a
skb containing the read CAN frame or a NULL pointer.

However the meaning of the NULL pointer is ambiguous, it can either mean
the requested mailbox is empty or there was an error.

This patch fixes this situation by returning:
- pointer to skb on success
- NULL pointer if mailbox is empty
- ERR_PTR(-ENOBUFS), if the maximal queue len is reached and a CAN frame
  is dropped.
- ERR_PTR(-ENOMEM) if no skb can be allocated and a CAN frame is
  dropped.

All users of can_rx_offload_offload_one() have been adopted, no
functional change intended.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/rx-offload.c | 54 ++++++++++++++++++++++++++++++++----
 1 file changed, 48 insertions(+), 6 deletions(-)

diff --git a/drivers/net/can/rx-offload.c b/drivers/net/can/rx-offload.c
index e224530a0630..2325890bbd14 100644
--- a/drivers/net/can/rx-offload.c
+++ b/drivers/net/can/rx-offload.c
@@ -107,29 +107,67 @@ static int can_rx_offload_compare(struct sk_buff *a, struct sk_buff *b)
 	return cb_b->timestamp - cb_a->timestamp;
 }
 
-static struct sk_buff *can_rx_offload_offload_one(struct can_rx_offload *offload, unsigned int n)
+/**
+ * can_rx_offload_offload_one() - Read one CAN frame from HW
+ * @offload: pointer to rx_offload context
+ * @n: number of mailbox to read
+ *
+ * The task of this function is to read a CAN frame from mailbox @n
+ * from the device and return the mailbox's content as a struct
+ * sk_buff.
+ *
+ * If the struct can_rx_offload::skb_queue exceeds the maximal queue
+ * length (struct can_rx_offload::skb_queue_len_max) or no skb can be
+ * allocated, the mailbox contents is discarded by reading it into an
+ * overflow buffer. This way the mailbox is marked as free by the
+ * driver.
+ *
+ * Return: A pointer to skb containing the CAN frame on success.
+ *
+ *         NULL if the mailbox @n is empty.
+ *
+ *         ERR_PTR(-ENOBUFS) if the maximal queue len is reached and a
+ *         CAN frame is dropped.
+ *
+ *         ERR_PTR(-ENOMEM) if no skb can be allocated and a CAN frame
+ *         is dropped.
+ */
+static struct sk_buff *
+can_rx_offload_offload_one(struct can_rx_offload *offload, unsigned int n)
 {
-	struct sk_buff *skb = NULL;
+	struct sk_buff *skb = NULL, *skb_error;
 	struct can_rx_offload_cb *cb;
 	struct can_frame *cf;
 	int ret;
 
-	/* If queue is full or skb not available, read to discard mailbox */
 	if (likely(skb_queue_len(&offload->skb_queue) <
-		   offload->skb_queue_len_max))
+		   offload->skb_queue_len_max)) {
 		skb = alloc_can_skb(offload->dev, &cf);
+		if (!skb)
+			skb_error = ERR_PTR(-ENOMEM);	/* skb alloc failed */
+	} else {
+		skb_error = ERR_PTR(-ENOBUFS);		/* skb_queue is full */
+	}
 
+	/* If queue is full or skb not available, drop by reading into
+	 * overflow buffer.
+	 */
 	if (!skb) {
 		struct can_frame cf_overflow;
 		u32 timestamp;
 
 		ret = offload->mailbox_read(offload, &cf_overflow,
 					    &timestamp, n);
+
+		/* A frame has been read and dropped. */
 		if (ret) {
 			offload->dev->stats.rx_dropped++;
 			offload->dev->stats.rx_fifo_errors++;
+
+			return skb_error;
 		}
 
+		/* No frame was read. */
 		return NULL;
 	}
 
@@ -159,7 +197,7 @@ int can_rx_offload_irq_offload_timestamp(struct can_rx_offload *offload, u64 pen
 			continue;
 
 		skb = can_rx_offload_offload_one(offload, i);
-		if (!skb)
+		if (IS_ERR_OR_NULL(skb))
 			break;
 
 		__skb_queue_add_sort(&skb_queue, skb, can_rx_offload_compare);
@@ -190,7 +228,11 @@ int can_rx_offload_irq_offload_fifo(struct can_rx_offload *offload)
 	struct sk_buff *skb;
 	int received = 0;
 
-	while ((skb = can_rx_offload_offload_one(offload, 0))) {
+	while (1) {
+		skb = can_rx_offload_offload_one(offload, 0);
+		if (IS_ERR_OR_NULL(skb))
+			break;
+
 		skb_queue_tail(&offload->skb_queue, skb);
 		received++;
 	}
-- 
2.23.0

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

* [PATCH 17/29] can: rx-offload: can_rx_offload_irq_offload_timestamp(): continue on error
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (15 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 16/29] can: rx-offload: can_rx_offload_offload_one(): use ERR_PTR() to propagate error value in case of errors Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 18/29] can: rx-offload: can_rx_offload_irq_offload_fifo(): " Marc Kleine-Budde
                   ` (11 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Marc Kleine-Budde

From: Jeroen Hofstee <jhofstee@victronenergy.com>

In case of a resource shortage, i.e. the rx_offload queue will overflow
or a skb fails to be allocated (due to OOM),
can_rx_offload_offload_one() will call mailbox_read() to discard the
mailbox and return an ERR_PTR.

However can_rx_offload_irq_offload_timestamp() bails out in the error
case. In case of a resource shortage all mailboxes should be discarded,
to avoid an IRQ storm and give the system some time to recover.

Since can_rx_offload_irq_offload_timestamp() is typically called from a
while loop, all message will eventually be discarded. So lets continue
on error instead to discard them directly.

Signed-off-by: Jeroen Hofstee <jhofstee@victronenergy.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/rx-offload.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/rx-offload.c b/drivers/net/can/rx-offload.c
index 2325890bbd14..42a1b7d1c753 100644
--- a/drivers/net/can/rx-offload.c
+++ b/drivers/net/can/rx-offload.c
@@ -198,7 +198,7 @@ int can_rx_offload_irq_offload_timestamp(struct can_rx_offload *offload, u64 pen
 
 		skb = can_rx_offload_offload_one(offload, i);
 		if (IS_ERR_OR_NULL(skb))
-			break;
+			continue;
 
 		__skb_queue_add_sort(&skb_queue, skb, can_rx_offload_compare);
 	}
-- 
2.23.0

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

* [PATCH 18/29] can: rx-offload: can_rx_offload_irq_offload_fifo(): continue on error
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (16 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 17/29] can: rx-offload: can_rx_offload_irq_offload_timestamp(): continue on error Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 19/29] can: flexcan: increase error counters if skb enqueueing via can_rx_offload_queue_sorted() fails Marc Kleine-Budde
                   ` (10 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Marc Kleine-Budde

In case of a resource shortage, i.e. the rx_offload queue will overflow
or a skb fails to be allocated (due to OOM),
can_rx_offload_offload_one() will call mailbox_read() to discard the
mailbox and return an ERR_PTR.

If the hardware FIFO is empty can_rx_offload_offload_one() will return
NULL.

In case a CAN frame was read from the hardware,
can_rx_offload_offload_one() returns the skb containing it.

Without this patch can_rx_offload_irq_offload_fifo() bails out if no skb
returned, regardless of the reason.

Similar to can_rx_offload_irq_offload_timestamp() in case of a resource
shortage the whole FIFO should be discarded, to avoid an IRQ storm and
give the system some time to recover. However if the FIFO is empty the
loop can be left.

With this patch the loop is left in case of empty FIFO, but not on
errors.

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

diff --git a/drivers/net/can/rx-offload.c b/drivers/net/can/rx-offload.c
index 42a1b7d1c753..f6274dbb292c 100644
--- a/drivers/net/can/rx-offload.c
+++ b/drivers/net/can/rx-offload.c
@@ -230,7 +230,9 @@ int can_rx_offload_irq_offload_fifo(struct can_rx_offload *offload)
 
 	while (1) {
 		skb = can_rx_offload_offload_one(offload, 0);
-		if (IS_ERR_OR_NULL(skb))
+		if (IS_ERR(skb))
+			continue;
+		if (!skb)
 			break;
 
 		skb_queue_tail(&offload->skb_queue, skb);
-- 
2.23.0

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

* [PATCH 19/29] can: flexcan: increase error counters if skb enqueueing via can_rx_offload_queue_sorted() fails
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (17 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 18/29] can: rx-offload: can_rx_offload_irq_offload_fifo(): " Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 20/29] can: ti_hecc: ti_hecc_error(): " Marc Kleine-Budde
                   ` (9 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Marc Kleine-Budde

The call to can_rx_offload_queue_sorted() may fail and return an error
(in the current implementation due to resource shortage). The passed skb
is consumed.

This patch adds incrementing of the appropriate error counters to let
the device statistics reflect that there's a problem.

Reported-by: Martin Hundebøll <martin@geanix.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 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 1cd5179cb876..57f9a2f51085 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -677,6 +677,7 @@ static void flexcan_irq_bus_err(struct net_device *dev, u32 reg_esr)
 	struct can_frame *cf;
 	bool rx_errors = false, tx_errors = false;
 	u32 timestamp;
+	int err;
 
 	timestamp = priv->read(&regs->timer) << 16;
 
@@ -725,7 +726,9 @@ static void flexcan_irq_bus_err(struct net_device *dev, u32 reg_esr)
 	if (tx_errors)
 		dev->stats.tx_errors++;
 
-	can_rx_offload_queue_sorted(&priv->offload, skb, timestamp);
+	err = can_rx_offload_queue_sorted(&priv->offload, skb, timestamp);
+	if (err)
+		dev->stats.rx_fifo_errors++;
 }
 
 static void flexcan_irq_state(struct net_device *dev, u32 reg_esr)
@@ -738,6 +741,7 @@ static void flexcan_irq_state(struct net_device *dev, u32 reg_esr)
 	int flt;
 	struct can_berr_counter bec;
 	u32 timestamp;
+	int err;
 
 	timestamp = priv->read(&regs->timer) << 16;
 
@@ -769,7 +773,9 @@ static void flexcan_irq_state(struct net_device *dev, u32 reg_esr)
 	if (unlikely(new_state == CAN_STATE_BUS_OFF))
 		can_bus_off(dev);
 
-	can_rx_offload_queue_sorted(&priv->offload, skb, timestamp);
+	err = can_rx_offload_queue_sorted(&priv->offload, skb, timestamp);
+	if (err)
+		dev->stats.rx_fifo_errors++;
 }
 
 static inline struct flexcan_priv *rx_offload_to_priv(struct can_rx_offload *offload)
-- 
2.23.0

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

* [PATCH 20/29] can: ti_hecc: ti_hecc_error(): increase error counters if skb enqueueing via can_rx_offload_queue_sorted() fails
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (18 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 19/29] can: flexcan: increase error counters if skb enqueueing via can_rx_offload_queue_sorted() fails Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 21/29] can: ti_hecc: ti_hecc_stop(): stop the CPK on down Marc Kleine-Budde
                   ` (8 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Marc Kleine-Budde

The call to can_rx_offload_queue_sorted() may fail and return an error
(in the current implementation due to resource shortage). The passed skb
is consumed.

This patch adds incrementing of the appropriate error counters to let
the device statistics reflect that there's a problem.

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

diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
index f8b19eef5d26..91188e6d4f78 100644
--- a/drivers/net/can/ti_hecc.c
+++ b/drivers/net/can/ti_hecc.c
@@ -558,6 +558,7 @@ static int ti_hecc_error(struct net_device *ndev, int int_status,
 	struct can_frame *cf;
 	struct sk_buff *skb;
 	u32 timestamp;
+	int err;
 
 	/* propagate the error condition to the can stack */
 	skb = alloc_can_err_skb(ndev, &cf);
@@ -639,7 +640,9 @@ static int ti_hecc_error(struct net_device *ndev, int int_status,
 	}
 
 	timestamp = hecc_read(priv, HECC_CANLNT);
-	can_rx_offload_queue_sorted(&priv->offload, skb, timestamp);
+	err = can_rx_offload_queue_sorted(&priv->offload, skb, timestamp);
+	if (err)
+		ndev->stats.rx_fifo_errors++;
 
 	return 0;
 }
-- 
2.23.0

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

* [PATCH 21/29] can: ti_hecc: ti_hecc_stop(): stop the CPK on down
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (19 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 20/29] can: ti_hecc: ti_hecc_error(): " Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 22/29] can: ti_hecc: keep MIM and MD set Marc Kleine-Budde
                   ` (7 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Marc Kleine-Budde

From: Jeroen Hofstee <jhofstee@victronenergy.com>

When the interface goes down, the CPK should no longer take an active
part in the CAN-bus communication, like sending acks and error frames.
So enable configuration mode in ti_hecc_stop, so the CPK is no longer
active.

When a transceiver switch is present the acks and errors don't make it
to the bus, but disabling the CPK then does prevent oddities, like
ti_hecc_reset() failing, since the CPK can become bus-off and starts
counting the 11 bit recessive bits, which seems to block the reset. It
can also cause invalid interrupts and disrupt the CAN-bus, since
transmission can be stopped in the middle of a message, by disabling the
tranceiver while the CPK is sending.

Since the CPK is disabled after normal power on, it is typically only
seen when the interface is restarted.

Signed-off-by: Jeroen Hofstee <jhofstee@victronenergy.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/ti_hecc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
index 91188e6d4f78..eb8151154083 100644
--- a/drivers/net/can/ti_hecc.c
+++ b/drivers/net/can/ti_hecc.c
@@ -400,6 +400,9 @@ static void ti_hecc_stop(struct net_device *ndev)
 {
 	struct ti_hecc_priv *priv = netdev_priv(ndev);
 
+	/* Disable the CPK; stop sending, erroring and acking */
+	hecc_set_bit(priv, HECC_CANMC, HECC_CANMC_CCR);
+
 	/* Disable interrupts and disable mailboxes */
 	hecc_write(priv, HECC_CANGIM, 0);
 	hecc_write(priv, HECC_CANMIM, 0);
-- 
2.23.0

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

* [PATCH 22/29] can: ti_hecc: keep MIM and MD set
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (20 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 21/29] can: ti_hecc: ti_hecc_stop(): stop the CPK on down Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 23/29] can: ti_hecc: release the mailbox a bit earlier Marc Kleine-Budde
                   ` (6 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Marc Kleine-Budde

From: Jeroen Hofstee <jhofstee@victronenergy.com>

The HECC_CANMIM is set in the xmit path and cleared in the interrupt.
Since this is done with a read, modify, write action the register might
end up with some more MIM enabled then intended, since it is not
protected. That doesn't matter at all, since the tx interrupt disables
the mailbox with HECC_CANME (while holding a spinlock). So lets just
always keep MIM set.

While at it, since the mailbox direction never changes, don't set it
every time a message is send, ti_hecc_reset() already sets them to tx.

Signed-off-by: Jeroen Hofstee <jhofstee@victronenergy.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/ti_hecc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
index eb8151154083..d6a84f8ff863 100644
--- a/drivers/net/can/ti_hecc.c
+++ b/drivers/net/can/ti_hecc.c
@@ -382,6 +382,9 @@ static void ti_hecc_start(struct net_device *ndev)
 		hecc_set_bit(priv, HECC_CANMIM, mbx_mask);
 	}
 
+	/* Enable tx interrupts */
+	hecc_set_bit(priv, HECC_CANMIM, BIT(HECC_MAX_TX_MBOX) - 1);
+
 	/* Prevent message over-write & Enable interrupts */
 	hecc_write(priv, HECC_CANOPC, HECC_SET_REG);
 	if (priv->use_hecc1int) {
@@ -511,8 +514,6 @@ static netdev_tx_t ti_hecc_xmit(struct sk_buff *skb, struct net_device *ndev)
 	hecc_set_bit(priv, HECC_CANME, mbx_mask);
 	spin_unlock_irqrestore(&priv->mbx_lock, flags);
 
-	hecc_clear_bit(priv, HECC_CANMD, mbx_mask);
-	hecc_set_bit(priv, HECC_CANMIM, mbx_mask);
 	hecc_write(priv, HECC_CANTRS, mbx_mask);
 
 	return NETDEV_TX_OK;
@@ -676,7 +677,6 @@ static irqreturn_t ti_hecc_interrupt(int irq, void *dev_id)
 			mbx_mask = BIT(mbxno);
 			if (!(mbx_mask & hecc_read(priv, HECC_CANTA)))
 				break;
-			hecc_clear_bit(priv, HECC_CANMIM, mbx_mask);
 			hecc_write(priv, HECC_CANTA, mbx_mask);
 			spin_lock_irqsave(&priv->mbx_lock, flags);
 			hecc_clear_bit(priv, HECC_CANME, mbx_mask);
-- 
2.23.0

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

* [PATCH 23/29] can: ti_hecc: release the mailbox a bit earlier
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (21 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 22/29] can: ti_hecc: keep MIM and MD set Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 24/29] can: ti_hecc: add fifo underflow error reporting Marc Kleine-Budde
                   ` (5 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Marc Kleine-Budde

From: Jeroen Hofstee <jhofstee@victronenergy.com>

Release the mailbox after reading it, so it can be reused a bit earlier.
Since "can: rx-offload: continue on error" all pending message bits are
cleared directly, so remove clearing them in ti_hecc.

Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Jeroen Hofstee <jhofstee@victronenergy.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/ti_hecc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
index d6a84f8ff863..6ea29126c60b 100644
--- a/drivers/net/can/ti_hecc.c
+++ b/drivers/net/can/ti_hecc.c
@@ -530,8 +530,9 @@ static unsigned int ti_hecc_mailbox_read(struct can_rx_offload *offload,
 					 u32 *timestamp, unsigned int mbxno)
 {
 	struct ti_hecc_priv *priv = rx_offload_to_priv(offload);
-	u32 data;
+	u32 data, mbx_mask;
 
+	mbx_mask = BIT(mbxno);
 	data = hecc_read_mbx(priv, mbxno, HECC_CANMID);
 	if (data & HECC_CANMID_IDE)
 		cf->can_id = (data & CAN_EFF_MASK) | CAN_EFF_FLAG;
@@ -551,6 +552,7 @@ static unsigned int ti_hecc_mailbox_read(struct can_rx_offload *offload,
 	}
 
 	*timestamp = hecc_read_stamp(priv, mbxno);
+	hecc_write(priv, HECC_CANRMP, mbx_mask);
 
 	return 1;
 }
@@ -701,7 +703,6 @@ static irqreturn_t ti_hecc_interrupt(int irq, void *dev_id)
 		while ((rx_pending = hecc_read(priv, HECC_CANRMP))) {
 			can_rx_offload_irq_offload_timestamp(&priv->offload,
 							     rx_pending);
-			hecc_write(priv, HECC_CANRMP, rx_pending);
 		}
 	}
 
-- 
2.23.0

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

* [PATCH 24/29] can: ti_hecc: add fifo underflow error reporting
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (22 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 23/29] can: ti_hecc: release the mailbox a bit earlier Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 15:52   ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 25/29] can: ti_hecc: properly report state changes Marc Kleine-Budde
                   ` (4 subsequent siblings)
  28 siblings, 1 reply; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Marc Kleine-Budde

From: Jeroen Hofstee <jhofstee@victronenergy.com>

When the rx fifo overflows the ti_hecc would silently drop them since
the overwrite protection is enabled for all mailboxes. So disable it
for the lowest priority mailbox and increment the rx_fifo_errors when
receive message lost is set. Drop the message itself in that case,
since it might be partially updated.

Signed-off-by: Jeroen Hofstee <jhofstee@victronenergy.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/ti_hecc.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
index 6ea29126c60b..c2d83ada203a 100644
--- a/drivers/net/can/ti_hecc.c
+++ b/drivers/net/can/ti_hecc.c
@@ -82,7 +82,7 @@ MODULE_VERSION(HECC_MODULE_VERSION);
 #define HECC_CANTA		0x10	/* Transmission acknowledge */
 #define HECC_CANAA		0x14	/* Abort acknowledge */
 #define HECC_CANRMP		0x18	/* Receive message pending */
-#define HECC_CANRML		0x1C	/* Remote message lost */
+#define HECC_CANRML		0x1C	/* Receive message lost */
 #define HECC_CANRFP		0x20	/* Remote frame pending */
 #define HECC_CANGAM		0x24	/* SECC only:Global acceptance mask */
 #define HECC_CANMC		0x28	/* Master control */
@@ -385,8 +385,17 @@ static void ti_hecc_start(struct net_device *ndev)
 	/* Enable tx interrupts */
 	hecc_set_bit(priv, HECC_CANMIM, BIT(HECC_MAX_TX_MBOX) - 1);
 
-	/* Prevent message over-write & Enable interrupts */
-	hecc_write(priv, HECC_CANOPC, HECC_SET_REG);
+	/* Prevent message over-write to create a rx fifo, but not for
+	 * the lowest priority mailbox, since that allows detecting
+	 * overflows instead of the hardware silently dropping the
+	 * messages. The lowest rx mailbox is one above the tx ones,
+	 * hence its mbxno is the number of tx mailboxes.
+	 */
+	mbxno = HECC_MAX_TX_MBOX;
+	mbx_mask = ~BIT(mbxno);
+	hecc_write(priv, HECC_CANOPC, mbx_mask);
+
+	/* Enable interrupts */
 	if (priv->use_hecc1int) {
 		hecc_write(priv, HECC_CANMIL, HECC_SET_REG);
 		hecc_write(priv, HECC_CANGIM, HECC_CANGIM_DEF_MASK |
@@ -531,6 +540,7 @@ static unsigned int ti_hecc_mailbox_read(struct can_rx_offload *offload,
 {
 	struct ti_hecc_priv *priv = rx_offload_to_priv(offload);
 	u32 data, mbx_mask;
+	int lost;
 
 	mbx_mask = BIT(mbxno);
 	data = hecc_read_mbx(priv, mbxno, HECC_CANMID);
@@ -552,9 +562,12 @@ static unsigned int ti_hecc_mailbox_read(struct can_rx_offload *offload,
 	}
 
 	*timestamp = hecc_read_stamp(priv, mbxno);
+	lost = hecc_read(priv, HECC_CANRML) & mbx_mask;
+	if (unlikely(lost))
+		priv->offload.dev->stats.rx_fifo_errors++;
 	hecc_write(priv, HECC_CANRMP, mbx_mask);
 
-	return 1;
+	return !lost;
 }
 
 static int ti_hecc_error(struct net_device *ndev, int int_status,
-- 
2.23.0

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

* [PATCH 25/29] can: ti_hecc: properly report state changes
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (23 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 24/29] can: ti_hecc: add fifo underflow error reporting Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 26/29] can: ti_hecc: add missing " Marc Kleine-Budde
                   ` (3 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Marc Kleine-Budde

From: Jeroen Hofstee <jhofstee@victronenergy.com>

The HECC_CANES register handles the flags specially, it only updates
the flags after a one is written to them. Since the interrupt for
frame errors is not enabled an old error can hence been seen when a
state interrupt arrives. For example if the device is not connected
to the CAN-bus the error warning interrupt will have HECC_CANES
indicating there is no ack. The error passive interrupt thereafter
will have HECC_CANES flagging that there is a warning level. And if
thereafter there is a message successfully send HECC_CANES points to
an error passive event, while in reality it became error warning
again. In summary, the state is not always reported correctly.

So handle the state changes and frame errors separately. The state
changes are now based on the interrupt flags and handled directly
when they occur. The reporting of the frame errors is still done as
before, as a side effect of another interrupt.

note: the hecc_clear_bit will do a read, modify, write. So it will
not only clear the bit, but also reset all other bits being set as
a side affect, hence it is replaced with only clearing the flags.

note: The HECC_CANMC_CCR is no longer cleared in the state change
interrupt, it is completely unrelated.

And use net_ratelimit to make checkpatch happy.

Signed-off-by: Jeroen Hofstee <jhofstee@victronenergy.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/ti_hecc.c | 162 +++++++++++++++++++++-----------------
 1 file changed, 88 insertions(+), 74 deletions(-)

diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
index c2d83ada203a..ffd90952cd97 100644
--- a/drivers/net/can/ti_hecc.c
+++ b/drivers/net/can/ti_hecc.c
@@ -149,6 +149,8 @@ MODULE_VERSION(HECC_MODULE_VERSION);
 #define HECC_BUS_ERROR		(HECC_CANES_FE | HECC_CANES_BE |\
 				HECC_CANES_CRCE | HECC_CANES_SE |\
 				HECC_CANES_ACKE)
+#define HECC_CANES_FLAGS	(HECC_BUS_ERROR | HECC_CANES_BO |\
+				HECC_CANES_EP | HECC_CANES_EW)
 
 #define HECC_CANMCF_RTR		BIT(4)	/* Remote transmit request */
 
@@ -579,91 +581,69 @@ static int ti_hecc_error(struct net_device *ndev, int int_status,
 	u32 timestamp;
 	int err;
 
-	/* propagate the error condition to the can stack */
-	skb = alloc_can_err_skb(ndev, &cf);
-	if (!skb) {
-		if (printk_ratelimit())
-			netdev_err(priv->ndev,
-				   "%s: alloc_can_err_skb() failed\n",
-				   __func__);
-		return -ENOMEM;
-	}
-
-	if (int_status & HECC_CANGIF_WLIF) { /* warning level int */
-		if ((int_status & HECC_CANGIF_BOIF) == 0) {
-			priv->can.state = CAN_STATE_ERROR_WARNING;
-			++priv->can.can_stats.error_warning;
-			cf->can_id |= CAN_ERR_CRTL;
-			if (hecc_read(priv, HECC_CANTEC) > 96)
-				cf->data[1] |= CAN_ERR_CRTL_TX_WARNING;
-			if (hecc_read(priv, HECC_CANREC) > 96)
-				cf->data[1] |= CAN_ERR_CRTL_RX_WARNING;
-		}
-		hecc_set_bit(priv, HECC_CANES, HECC_CANES_EW);
-		netdev_dbg(priv->ndev, "Error Warning interrupt\n");
-		hecc_clear_bit(priv, HECC_CANMC, HECC_CANMC_CCR);
-	}
-
-	if (int_status & HECC_CANGIF_EPIF) { /* error passive int */
-		if ((int_status & HECC_CANGIF_BOIF) == 0) {
-			priv->can.state = CAN_STATE_ERROR_PASSIVE;
-			++priv->can.can_stats.error_passive;
-			cf->can_id |= CAN_ERR_CRTL;
-			if (hecc_read(priv, HECC_CANTEC) > 127)
-				cf->data[1] |= CAN_ERR_CRTL_TX_PASSIVE;
-			if (hecc_read(priv, HECC_CANREC) > 127)
-				cf->data[1] |= CAN_ERR_CRTL_RX_PASSIVE;
+	if (err_status & HECC_BUS_ERROR) {
+		/* propagate the error condition to the can stack */
+		skb = alloc_can_err_skb(ndev, &cf);
+		if (!skb) {
+			if (net_ratelimit())
+				netdev_err(priv->ndev,
+					   "%s: alloc_can_err_skb() failed\n",
+					   __func__);
+			return -ENOMEM;
 		}
-		hecc_set_bit(priv, HECC_CANES, HECC_CANES_EP);
-		netdev_dbg(priv->ndev, "Error passive interrupt\n");
-		hecc_clear_bit(priv, HECC_CANMC, HECC_CANMC_CCR);
-	}
-
-	/* Need to check busoff condition in error status register too to
-	 * ensure warning interrupts don't hog the system
-	 */
-	if ((int_status & HECC_CANGIF_BOIF) || (err_status & HECC_CANES_BO)) {
-		priv->can.state = CAN_STATE_BUS_OFF;
-		cf->can_id |= CAN_ERR_BUSOFF;
-		hecc_set_bit(priv, HECC_CANES, HECC_CANES_BO);
-		hecc_clear_bit(priv, HECC_CANMC, HECC_CANMC_CCR);
-		/* Disable all interrupts in bus-off to avoid int hog */
-		hecc_write(priv, HECC_CANGIM, 0);
-		++priv->can.can_stats.bus_off;
-		can_bus_off(ndev);
-	}
 
-	if (err_status & HECC_BUS_ERROR) {
 		++priv->can.can_stats.bus_error;
 		cf->can_id |= CAN_ERR_BUSERROR | CAN_ERR_PROT;
-		if (err_status & HECC_CANES_FE) {
-			hecc_set_bit(priv, HECC_CANES, HECC_CANES_FE);
+		if (err_status & HECC_CANES_FE)
 			cf->data[2] |= CAN_ERR_PROT_FORM;
-		}
-		if (err_status & HECC_CANES_BE) {
-			hecc_set_bit(priv, HECC_CANES, HECC_CANES_BE);
+		if (err_status & HECC_CANES_BE)
 			cf->data[2] |= CAN_ERR_PROT_BIT;
-		}
-		if (err_status & HECC_CANES_SE) {
-			hecc_set_bit(priv, HECC_CANES, HECC_CANES_SE);
+		if (err_status & HECC_CANES_SE)
 			cf->data[2] |= CAN_ERR_PROT_STUFF;
-		}
-		if (err_status & HECC_CANES_CRCE) {
-			hecc_set_bit(priv, HECC_CANES, HECC_CANES_CRCE);
+		if (err_status & HECC_CANES_CRCE)
 			cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
-		}
-		if (err_status & HECC_CANES_ACKE) {
-			hecc_set_bit(priv, HECC_CANES, HECC_CANES_ACKE);
+		if (err_status & HECC_CANES_ACKE)
 			cf->data[3] = CAN_ERR_PROT_LOC_ACK;
-		}
+
+		timestamp = hecc_read(priv, HECC_CANLNT);
+		err = can_rx_offload_queue_sorted(&priv->offload, skb,
+						  timestamp);
+		if (err)
+			ndev->stats.rx_fifo_errors++;
+	}
+
+	hecc_write(priv, HECC_CANES, HECC_CANES_FLAGS);
+
+	return 0;
+}
+
+static void ti_hecc_change_state(struct net_device *ndev,
+				 enum can_state rx_state,
+				 enum can_state tx_state)
+{
+	struct ti_hecc_priv *priv = netdev_priv(ndev);
+	struct can_frame *cf;
+	struct sk_buff *skb;
+	u32 timestamp;
+	int err;
+
+	skb = alloc_can_err_skb(priv->ndev, &cf);
+	if (unlikely(!skb)) {
+		priv->can.state = max(tx_state, rx_state);
+		return;
+	}
+
+	can_change_state(priv->ndev, cf, tx_state, rx_state);
+
+	if (max(tx_state, rx_state) != CAN_STATE_BUS_OFF) {
+		cf->data[6] = hecc_read(priv, HECC_CANTEC);
+		cf->data[7] = hecc_read(priv, HECC_CANREC);
 	}
 
 	timestamp = hecc_read(priv, HECC_CANLNT);
 	err = can_rx_offload_queue_sorted(&priv->offload, skb, timestamp);
 	if (err)
 		ndev->stats.rx_fifo_errors++;
-
-	return 0;
 }
 
 static irqreturn_t ti_hecc_interrupt(int irq, void *dev_id)
@@ -673,6 +653,7 @@ static irqreturn_t ti_hecc_interrupt(int irq, void *dev_id)
 	struct net_device_stats *stats = &ndev->stats;
 	u32 mbxno, mbx_mask, int_status, err_status, stamp;
 	unsigned long flags, rx_pending;
+	u32 handled = 0;
 
 	int_status = hecc_read(priv,
 			       priv->use_hecc1int ?
@@ -682,10 +663,43 @@ static irqreturn_t ti_hecc_interrupt(int irq, void *dev_id)
 		return IRQ_NONE;
 
 	err_status = hecc_read(priv, HECC_CANES);
-	if (err_status & (HECC_BUS_ERROR | HECC_CANES_BO |
-			  HECC_CANES_EP | HECC_CANES_EW))
+	if (unlikely(err_status & HECC_CANES_FLAGS))
 		ti_hecc_error(ndev, int_status, err_status);
 
+	if (unlikely(int_status & HECC_CANGIM_DEF_MASK)) {
+		enum can_state rx_state, tx_state;
+		u32 rec = hecc_read(priv, HECC_CANREC);
+		u32 tec = hecc_read(priv, HECC_CANTEC);
+
+		if (int_status & HECC_CANGIF_WLIF) {
+			handled |= HECC_CANGIF_WLIF;
+			rx_state = rec >= tec ? CAN_STATE_ERROR_WARNING : 0;
+			tx_state = rec <= tec ? CAN_STATE_ERROR_WARNING : 0;
+			netdev_dbg(priv->ndev, "Error Warning interrupt\n");
+			ti_hecc_change_state(ndev, rx_state, tx_state);
+		}
+
+		if (int_status & HECC_CANGIF_EPIF) {
+			handled |= HECC_CANGIF_EPIF;
+			rx_state = rec >= tec ? CAN_STATE_ERROR_PASSIVE : 0;
+			tx_state = rec <= tec ? CAN_STATE_ERROR_PASSIVE : 0;
+			netdev_dbg(priv->ndev, "Error passive interrupt\n");
+			ti_hecc_change_state(ndev, rx_state, tx_state);
+		}
+
+		if (int_status & HECC_CANGIF_BOIF) {
+			handled |= HECC_CANGIF_BOIF;
+			rx_state = CAN_STATE_BUS_OFF;
+			tx_state = CAN_STATE_BUS_OFF;
+			netdev_dbg(priv->ndev, "Bus off interrupt\n");
+
+			/* Disable all interrupts */
+			hecc_write(priv, HECC_CANGIM, 0);
+			can_bus_off(ndev);
+			ti_hecc_change_state(ndev, rx_state, tx_state);
+		}
+	}
+
 	if (int_status & HECC_CANGIF_GMIF) {
 		while (priv->tx_tail - priv->tx_head > 0) {
 			mbxno = get_tx_tail_mb(priv);
@@ -721,10 +735,10 @@ static irqreturn_t ti_hecc_interrupt(int irq, void *dev_id)
 
 	/* clear all interrupt conditions - read back to avoid spurious ints */
 	if (priv->use_hecc1int) {
-		hecc_write(priv, HECC_CANGIF1, HECC_SET_REG);
+		hecc_write(priv, HECC_CANGIF1, handled);
 		int_status = hecc_read(priv, HECC_CANGIF1);
 	} else {
-		hecc_write(priv, HECC_CANGIF0, HECC_SET_REG);
+		hecc_write(priv, HECC_CANGIF0, handled);
 		int_status = hecc_read(priv, HECC_CANGIF0);
 	}
 
-- 
2.23.0

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

* [PATCH 26/29] can: ti_hecc: add missing state changes
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (24 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 25/29] can: ti_hecc: properly report state changes Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 27/29] can: j1939: fix resource leak of skb on error return paths Marc Kleine-Budde
                   ` (2 subsequent siblings)
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Marc Kleine-Budde

From: Jeroen Hofstee <jhofstee@victronenergy.com>

While the ti_hecc has interrupts to report when the error counters increase
to a certain level and which change state it doesn't handle the case that
the error counters go down again, so the reported state can actually be
wrong. Since there is no interrupt for that, do update state based on the
error counters, when the state is not error active and goes down again.

Signed-off-by: Jeroen Hofstee <jhofstee@victronenergy.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/ti_hecc.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
index ffd90952cd97..ba0fbe771e36 100644
--- a/drivers/net/can/ti_hecc.c
+++ b/drivers/net/can/ti_hecc.c
@@ -698,6 +698,23 @@ static irqreturn_t ti_hecc_interrupt(int irq, void *dev_id)
 			can_bus_off(ndev);
 			ti_hecc_change_state(ndev, rx_state, tx_state);
 		}
+	} else if (unlikely(priv->can.state != CAN_STATE_ERROR_ACTIVE)) {
+		enum can_state new_state, tx_state, rx_state;
+		u32 rec = hecc_read(priv, HECC_CANREC);
+		u32 tec = hecc_read(priv, HECC_CANTEC);
+
+		if (rec >= 128 || tec >= 128)
+			new_state = CAN_STATE_ERROR_PASSIVE;
+		else if (rec >= 96 || tec >= 96)
+			new_state = CAN_STATE_ERROR_WARNING;
+		else
+			new_state = CAN_STATE_ERROR_ACTIVE;
+
+		if (new_state < priv->can.state) {
+			rx_state = rec >= tec ? new_state : 0;
+			tx_state = rec <= tec ? new_state : 0;
+			ti_hecc_change_state(ndev, rx_state, tx_state);
+		}
 	}
 
 	if (int_status & HECC_CANGIF_GMIF) {
-- 
2.23.0

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

* [PATCH 27/29] can: j1939: fix resource leak of skb on error return paths
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (25 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 26/29] can: ti_hecc: add missing " Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 28/29] can: j1939: fix memory leak if filters was set Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 29/29] can: don't use deprecated license identifiers Marc Kleine-Budde
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Colin Ian King, Oleksij Rempel, Marc Kleine-Budde

From: Colin Ian King <colin.king@canonical.com>

Currently the error return paths do not free skb and this results in a
memory leak. Fix this by freeing them before the return.

Addresses-Coverity: ("Resource leak")
Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 net/can/j1939/socket.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c
index 37c1040bcb9c..5c6eabcb5df1 100644
--- a/net/can/j1939/socket.c
+++ b/net/can/j1939/socket.c
@@ -909,8 +909,10 @@ void j1939_sk_errqueue(struct j1939_session *session,
 	memset(serr, 0, sizeof(*serr));
 	switch (type) {
 	case J1939_ERRQUEUE_ACK:
-		if (!(sk->sk_tsflags & SOF_TIMESTAMPING_TX_ACK))
+		if (!(sk->sk_tsflags & SOF_TIMESTAMPING_TX_ACK)) {
+			kfree_skb(skb);
 			return;
+		}
 
 		serr->ee.ee_errno = ENOMSG;
 		serr->ee.ee_origin = SO_EE_ORIGIN_TIMESTAMPING;
@@ -918,8 +920,10 @@ void j1939_sk_errqueue(struct j1939_session *session,
 		state = "ACK";
 		break;
 	case J1939_ERRQUEUE_SCHED:
-		if (!(sk->sk_tsflags & SOF_TIMESTAMPING_TX_SCHED))
+		if (!(sk->sk_tsflags & SOF_TIMESTAMPING_TX_SCHED)) {
+			kfree_skb(skb);
 			return;
+		}
 
 		serr->ee.ee_errno = ENOMSG;
 		serr->ee.ee_origin = SO_EE_ORIGIN_TIMESTAMPING;
-- 
2.23.0

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

* [PATCH 28/29] can: j1939: fix memory leak if filters was set
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (26 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 27/29] can: j1939: fix resource leak of skb on error return paths Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  2019-10-10 12:17 ` [PATCH 29/29] can: don't use deprecated license identifiers Marc Kleine-Budde
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Oleksij Rempel, Marc Kleine-Budde

From: Oleksij Rempel <o.rempel@pengutronix.de>

Filters array is coped from user space and linked to the j1939 socket.
On socket release this memory was not freed.

Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 net/can/j1939/socket.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c
index 5c6eabcb5df1..4d8ba701e15d 100644
--- a/net/can/j1939/socket.c
+++ b/net/can/j1939/socket.c
@@ -580,6 +580,7 @@ static int j1939_sk_release(struct socket *sock)
 		j1939_netdev_stop(priv);
 	}
 
+	kfree(jsk->filters);
 	sock_orphan(sk);
 	sock->sk = NULL;
 
-- 
2.23.0

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

* [PATCH 29/29] can: don't use deprecated license identifiers
  2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
                   ` (27 preceding siblings ...)
  2019-10-10 12:17 ` [PATCH 28/29] can: j1939: fix memory leak if filters was set Marc Kleine-Budde
@ 2019-10-10 12:17 ` Marc Kleine-Budde
  28 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 12:17 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: davem, kernel, jhofstee, Martin Hundebøll, Kurt Van Dijck,
	Yegor Yefremov, Oliver Hartkopp, Marc Kleine-Budde

From: Yegor Yefremov <yegorslists@googlemail.com>

The "GPL-2.0" license identifier changed to "GPL-2.0-only" in SPDX v3.0.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 include/uapi/linux/can.h         | 2 +-
 include/uapi/linux/can/bcm.h     | 2 +-
 include/uapi/linux/can/error.h   | 2 +-
 include/uapi/linux/can/gw.h      | 2 +-
 include/uapi/linux/can/j1939.h   | 2 +-
 include/uapi/linux/can/netlink.h | 2 +-
 include/uapi/linux/can/raw.h     | 2 +-
 include/uapi/linux/can/vxcan.h   | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/uapi/linux/can.h b/include/uapi/linux/can.h
index 1e988fdeba34..6a6d2c7655ff 100644
--- a/include/uapi/linux/can.h
+++ b/include/uapi/linux/can.h
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
+/* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */
 /*
  * linux/can.h
  *
diff --git a/include/uapi/linux/can/bcm.h b/include/uapi/linux/can/bcm.h
index 0fb328d93148..dd2b925b09ac 100644
--- a/include/uapi/linux/can/bcm.h
+++ b/include/uapi/linux/can/bcm.h
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
+/* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */
 /*
  * linux/can/bcm.h
  *
diff --git a/include/uapi/linux/can/error.h b/include/uapi/linux/can/error.h
index bfc4b5d22a5e..34633283de64 100644
--- a/include/uapi/linux/can/error.h
+++ b/include/uapi/linux/can/error.h
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
+/* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */
 /*
  * linux/can/error.h
  *
diff --git a/include/uapi/linux/can/gw.h b/include/uapi/linux/can/gw.h
index 3aea5388c8e4..c2190bbe21d8 100644
--- a/include/uapi/linux/can/gw.h
+++ b/include/uapi/linux/can/gw.h
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
+/* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */
 /*
  * linux/can/gw.h
  *
diff --git a/include/uapi/linux/can/j1939.h b/include/uapi/linux/can/j1939.h
index c32325342d30..df6e821075c1 100644
--- a/include/uapi/linux/can/j1939.h
+++ b/include/uapi/linux/can/j1939.h
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
 /*
  * j1939.h
  *
diff --git a/include/uapi/linux/can/netlink.h b/include/uapi/linux/can/netlink.h
index 1bc70d3a4d39..6f598b73839e 100644
--- a/include/uapi/linux/can/netlink.h
+++ b/include/uapi/linux/can/netlink.h
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
 /*
  * linux/can/netlink.h
  *
diff --git a/include/uapi/linux/can/raw.h b/include/uapi/linux/can/raw.h
index be3b36e7ff61..6a11d308eb5c 100644
--- a/include/uapi/linux/can/raw.h
+++ b/include/uapi/linux/can/raw.h
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
+/* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */
 /*
  * linux/can/raw.h
  *
diff --git a/include/uapi/linux/can/vxcan.h b/include/uapi/linux/can/vxcan.h
index 066812d118a2..4fa9d8777a07 100644
--- a/include/uapi/linux/can/vxcan.h
+++ b/include/uapi/linux/can/vxcan.h
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
 #ifndef _UAPI_CAN_VXCAN_H
 #define _UAPI_CAN_VXCAN_H
 
-- 
2.23.0

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

* Re: [PATCH 24/29] can: ti_hecc: add fifo underflow error reporting
  2019-10-10 12:17 ` [PATCH 24/29] can: ti_hecc: add fifo underflow error reporting Marc Kleine-Budde
@ 2019-10-10 15:52   ` Marc Kleine-Budde
  2019-10-10 18:04     ` Jeroen Hofstee
       [not found]     ` <694ef4e8-166b-7eeb-4d6e-39a0ecacc93f@victronenergy.com>
  0 siblings, 2 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 15:52 UTC (permalink / raw)
  To: netdev, linux-can
  Cc: Kurt Van Dijck, Martin Hundebøll, jhofstee, kernel, davem


[-- Attachment #1.1: Type: text/plain, Size: 3812 bytes --]

On 10/10/19 2:17 PM, Marc Kleine-Budde wrote:
> From: Jeroen Hofstee <jhofstee@victronenergy.com>
> 
> When the rx fifo overflows the ti_hecc would silently drop them since
> the overwrite protection is enabled for all mailboxes. So disable it
> for the lowest priority mailbox and increment the rx_fifo_errors when
> receive message lost is set. Drop the message itself in that case,
> since it might be partially updated.

Is that your observation or does the data sheet say anything to this
situation?

> 
> Signed-off-by: Jeroen Hofstee <jhofstee@victronenergy.com>
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> ---
>  drivers/net/can/ti_hecc.c | 21 +++++++++++++++++----
>  1 file changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
> index 6ea29126c60b..c2d83ada203a 100644
> --- a/drivers/net/can/ti_hecc.c
> +++ b/drivers/net/can/ti_hecc.c
> @@ -82,7 +82,7 @@ MODULE_VERSION(HECC_MODULE_VERSION);
>  #define HECC_CANTA		0x10	/* Transmission acknowledge */
>  #define HECC_CANAA		0x14	/* Abort acknowledge */
>  #define HECC_CANRMP		0x18	/* Receive message pending */
> -#define HECC_CANRML		0x1C	/* Remote message lost */
> +#define HECC_CANRML		0x1C	/* Receive message lost */
>  #define HECC_CANRFP		0x20	/* Remote frame pending */
>  #define HECC_CANGAM		0x24	/* SECC only:Global acceptance mask */
>  #define HECC_CANMC		0x28	/* Master control */
> @@ -385,8 +385,17 @@ static void ti_hecc_start(struct net_device *ndev)
>  	/* Enable tx interrupts */
>  	hecc_set_bit(priv, HECC_CANMIM, BIT(HECC_MAX_TX_MBOX) - 1);
>  
> -	/* Prevent message over-write & Enable interrupts */
> -	hecc_write(priv, HECC_CANOPC, HECC_SET_REG);
> +	/* Prevent message over-write to create a rx fifo, but not for
> +	 * the lowest priority mailbox, since that allows detecting
> +	 * overflows instead of the hardware silently dropping the
> +	 * messages. The lowest rx mailbox is one above the tx ones,
> +	 * hence its mbxno is the number of tx mailboxes.
> +	 */
> +	mbxno = HECC_MAX_TX_MBOX;
> +	mbx_mask = ~BIT(mbxno);
> +	hecc_write(priv, HECC_CANOPC, mbx_mask);
> +
> +	/* Enable interrupts */
>  	if (priv->use_hecc1int) {
>  		hecc_write(priv, HECC_CANMIL, HECC_SET_REG);
>  		hecc_write(priv, HECC_CANGIM, HECC_CANGIM_DEF_MASK |
> @@ -531,6 +540,7 @@ static unsigned int ti_hecc_mailbox_read(struct can_rx_offload *offload,
>  {
>  	struct ti_hecc_priv *priv = rx_offload_to_priv(offload);
>  	u32 data, mbx_mask;
> +	int lost;
>  
>  	mbx_mask = BIT(mbxno);
>  	data = hecc_read_mbx(priv, mbxno, HECC_CANMID);
> @@ -552,9 +562,12 @@ static unsigned int ti_hecc_mailbox_read(struct can_rx_offload *offload,
>  	}
>  
>  	*timestamp = hecc_read_stamp(priv, mbxno);
> +	lost = hecc_read(priv, HECC_CANRML) & mbx_mask;
> +	if (unlikely(lost))
> +		priv->offload.dev->stats.rx_fifo_errors++;

In the flexcan and at91_can driver we're incrementing the following errors:
			dev->stats.rx_over_errors++;
			dev->stats.rx_errors++;

You can save the register access if you only check for overflows if
reading from the lowest prio mailbox.

If you're discarding the data if the mailbox is marked as overflow
there's no need to read the data in the first place.

>  	hecc_write(priv, HECC_CANRMP, mbx_mask);
>  
> -	return 1;
> +	return !lost;
>  }
>  
>  static int ti_hecc_error(struct net_device *ndev, int int_status,
> 

I'll send a v2 that addresses these findings.

Marc

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


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

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

* Re: [PATCH 24/29] can: ti_hecc: add fifo underflow error reporting
  2019-10-10 15:52   ` Marc Kleine-Budde
@ 2019-10-10 18:04     ` Jeroen Hofstee
       [not found]     ` <694ef4e8-166b-7eeb-4d6e-39a0ecacc93f@victronenergy.com>
  1 sibling, 0 replies; 33+ messages in thread
From: Jeroen Hofstee @ 2019-10-10 18:04 UTC (permalink / raw)
  To: Marc Kleine-Budde, netdev, linux-can
  Cc: Kurt Van Dijck, Martin Hundebøll, kernel, davem

Attempt 2, now as plain text... (vger doesn't like html)

On 10/10/19 5:52 PM, Marc Kleine-Budde wrote:
> On 10/10/19 2:17 PM, Marc Kleine-Budde wrote:
>> From: Jeroen Hofstee <jhofstee@victronenergy.com>
>>
>> When the rx fifo overflows the ti_hecc would silently drop them since
>> the overwrite protection is enabled for all mailboxes. So disable it
>> for the lowest priority mailbox and increment the rx_fifo_errors when
>> receive message lost is set. Drop the message itself in that case,
>> since it might be partially updated.
> Is that your observation or does the data sheet say anything to this
> situation?


I couldn't find in the data sheet, so I simply tested it, by allowing
the highest mailbox to be overwritten and send a stream alternating
with messages will all bits set and all cleared. That does end with
canids from one message combined with data from another.


>> Signed-off-by: Jeroen Hofstee <jhofstee@victronenergy.com>
>> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
>> ---
>>   drivers/net/can/ti_hecc.c | 21 +++++++++++++++++----
>>   1 file changed, 17 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
>> index 6ea29126c60b..c2d83ada203a 100644
>> --- a/drivers/net/can/ti_hecc.c
>> +++ b/drivers/net/can/ti_hecc.c
>> @@ -82,7 +82,7 @@ MODULE_VERSION(HECC_MODULE_VERSION);
>>   #define HECC_CANTA		0x10	/* Transmission acknowledge */
>>   #define HECC_CANAA		0x14	/* Abort acknowledge */
>>   #define HECC_CANRMP		0x18	/* Receive message pending */
>> -#define HECC_CANRML		0x1C	/* Remote message lost */
>> +#define HECC_CANRML		0x1C	/* Receive message lost */
>>   #define HECC_CANRFP		0x20	/* Remote frame pending */
>>   #define HECC_CANGAM		0x24	/* SECC only:Global acceptance mask */
>>   #define HECC_CANMC		0x28	/* Master control */
>> @@ -385,8 +385,17 @@ static void ti_hecc_start(struct net_device *ndev)
>>   	/* Enable tx interrupts */
>>   	hecc_set_bit(priv, HECC_CANMIM, BIT(HECC_MAX_TX_MBOX) - 1);
>>   
>> -	/* Prevent message over-write & Enable interrupts */
>> -	hecc_write(priv, HECC_CANOPC, HECC_SET_REG);
>> +	/* Prevent message over-write to create a rx fifo, but not for
>> +	 * the lowest priority mailbox, since that allows detecting
>> +	 * overflows instead of the hardware silently dropping the
>> +	 * messages. The lowest rx mailbox is one above the tx ones,
>> +	 * hence its mbxno is the number of tx mailboxes.
>> +	 */
>> +	mbxno = HECC_MAX_TX_MBOX;
>> +	mbx_mask = ~BIT(mbxno);
>> +	hecc_write(priv, HECC_CANOPC, mbx_mask);
>> +
>> +	/* Enable interrupts */
>>   	if (priv->use_hecc1int) {
>>   		hecc_write(priv, HECC_CANMIL, HECC_SET_REG);
>>   		hecc_write(priv, HECC_CANGIM, HECC_CANGIM_DEF_MASK |
>> @@ -531,6 +540,7 @@ static unsigned int ti_hecc_mailbox_read(struct can_rx_offload *offload,
>>   {
>>   	struct ti_hecc_priv *priv = rx_offload_to_priv(offload);
>>   	u32 data, mbx_mask;
>> +	int lost;
>>   
>>   	mbx_mask = BIT(mbxno);
>>   	data = hecc_read_mbx(priv, mbxno, HECC_CANMID);
>> @@ -552,9 +562,12 @@ static unsigned int ti_hecc_mailbox_read(struct can_rx_offload *offload,
>>   	}
>>   
>>   	*timestamp = hecc_read_stamp(priv, mbxno);
>> +	lost = hecc_read(priv, HECC_CANRML) & mbx_mask;
>> +	if (unlikely(lost))
>> +		priv->offload.dev->stats.rx_fifo_errors++;
> In the flexcan and at91_can driver we're incrementing the following errors:
> 			dev->stats.rx_over_errors++;
> 			dev->stats.rx_errors++;


I understood it as follows, see[1] e.g.:

rx_errors -> link level errors, not really applicable to CAN
(perhaps in single shot mode or if you want (and can) report 
retransmissions)

rx_over_errors -> the hardware itself cannot keep up.
Not applicable for CAN.

rx_fifo_errors -> the software driver cannot keep up.
So I picked that one.

rx_dropped -> software is dropping on purpose based on limits etc.

But I might be wrong.


> You can save the register access if you only check for overflows if
> reading from the lowest prio mailbox.
>
> If you're discarding the data if the mailbox is marked as overflow
> there's no need to read the data in the first place.
>
>>   	hecc_write(priv, HECC_CANRMP, mbx_mask);
>>   
>> -	return 1;
>> +	return !lost;
>>   }
>>   
>>   static int ti_hecc_error(struct net_device *ndev, int int_status,
>>

Mind it that you don't cause a race! The bit can become set
during reading of the data, it should be check _after_ we
have a copy of the mailbox. You can do a double check, one
before one after, but since there should be no fifo overflow
anyway, there is no reason to optimize for that path. (@250k
I cannot get more then 3 messages in the fifo...).

Regards,

Jeroen

[1] 
https://community.mellanox.com/s/article/counters-troubleshooting-for-linux-driver 


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

* Re: [PATCH 24/29] can: ti_hecc: add fifo underflow error reporting
       [not found]     ` <694ef4e8-166b-7eeb-4d6e-39a0ecacc93f@victronenergy.com>
@ 2019-10-10 20:29       ` Marc Kleine-Budde
  0 siblings, 0 replies; 33+ messages in thread
From: Marc Kleine-Budde @ 2019-10-10 20:29 UTC (permalink / raw)
  To: Jeroen Hofstee, netdev, linux-can
  Cc: Martin Hundebøll, Kurt Van Dijck, davem, kernel


[-- Attachment #1.1: Type: text/plain, Size: 5593 bytes --]

On 10/10/19 7:51 PM, Jeroen Hofstee wrote:
>>> When the rx fifo overflows the ti_hecc would silently drop them since
>>> the overwrite protection is enabled for all mailboxes. So disable it
>>> for the lowest priority mailbox and increment the rx_fifo_errors when
>>> receive message lost is set. Drop the message itself in that case,
>>> since it might be partially updated.
>> Is that your observation or does the data sheet say anything to this
>> situation?
> 
> I couldn't find in the data sheet, so I simply tested it, by allowing
> the highest mailbox to be overwritten and send a stream alternating
> with messages will all bits set and all cleared. That does end with
> canids from one message combined with data from another.

I see. This is why the register is called overwrite _protection_ control.

>>> Signed-off-by: Jeroen Hofstee <jhofstee@victronenergy.com>
>>> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
>>> ---
>>>  drivers/net/can/ti_hecc.c | 21 +++++++++++++++++----
>>>  1 file changed, 17 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
>>> index 6ea29126c60b..c2d83ada203a 100644
>>> --- a/drivers/net/can/ti_hecc.c
>>> +++ b/drivers/net/can/ti_hecc.c
>>> @@ -82,7 +82,7 @@ MODULE_VERSION(HECC_MODULE_VERSION);
>>>  #define HECC_CANTA		0x10	/* Transmission acknowledge */
>>>  #define HECC_CANAA		0x14	/* Abort acknowledge */
>>>  #define HECC_CANRMP		0x18	/* Receive message pending */
>>> -#define HECC_CANRML		0x1C	/* Remote message lost */
>>> +#define HECC_CANRML		0x1C	/* Receive message lost */
>>>  #define HECC_CANRFP		0x20	/* Remote frame pending */
>>>  #define HECC_CANGAM		0x24	/* SECC only:Global acceptance mask */
>>>  #define HECC_CANMC		0x28	/* Master control */
>>> @@ -385,8 +385,17 @@ static void ti_hecc_start(struct net_device *ndev)
>>>  	/* Enable tx interrupts */
>>>  	hecc_set_bit(priv, HECC_CANMIM, BIT(HECC_MAX_TX_MBOX) - 1);
>>>  
>>> -	/* Prevent message over-write & Enable interrupts */
>>> -	hecc_write(priv, HECC_CANOPC, HECC_SET_REG);
>>> +	/* Prevent message over-write to create a rx fifo, but not for
>>> +	 * the lowest priority mailbox, since that allows detecting
>>> +	 * overflows instead of the hardware silently dropping the
>>> +	 * messages. The lowest rx mailbox is one above the tx ones,
>>> +	 * hence its mbxno is the number of tx mailboxes.
>>> +	 */
>>> +	mbxno = HECC_MAX_TX_MBOX;
>>> +	mbx_mask = ~BIT(mbxno);
>>> +	hecc_write(priv, HECC_CANOPC, mbx_mask);
>>> +
>>> +	/* Enable interrupts */
>>>  	if (priv->use_hecc1int) {
>>>  		hecc_write(priv, HECC_CANMIL, HECC_SET_REG);
>>>  		hecc_write(priv, HECC_CANGIM, HECC_CANGIM_DEF_MASK |
>>> @@ -531,6 +540,7 @@ static unsigned int ti_hecc_mailbox_read(struct can_rx_offload *offload,
>>>  {
>>>  	struct ti_hecc_priv *priv = rx_offload_to_priv(offload);
>>>  	u32 data, mbx_mask;
>>> +	int lost;
>>>  
>>>  	mbx_mask = BIT(mbxno);
>>>  	data = hecc_read_mbx(priv, mbxno, HECC_CANMID);
>>> @@ -552,9 +562,12 @@ static unsigned int ti_hecc_mailbox_read(struct can_rx_offload *offload,
>>>  	}
>>>  
>>>  	*timestamp = hecc_read_stamp(priv, mbxno);
>>> +	lost = hecc_read(priv, HECC_CANRML) & mbx_mask;
>>> +	if (unlikely(lost))
>>> +		priv->offload.dev->stats.rx_fifo_errors++;
>> In the flexcan and at91_can driver we're incrementing the following errors:
>> 			dev->stats.rx_over_errors++;
>> 			dev->stats.rx_errors++;
> 
> I understood it as follows, see[1] e.g.:
>
> rx_errors -> link level errors, not really applicable to CAN
> (perhaps in single shot mode or if you want)

I increment this for CRC, bit stuffing and all the other bus errors. As
well as on HW FIFO overflows.

> rx_over_errors -> the hardware itself cannot keep up.
> Not applicable for CAN.

If the HW FIFO overflows for whatever reason, I increment this.

> rx_fifo_errors -> the software driver cannot keep up.
> So I picked that one.

If the rx-offload queue reaches it's limit I increment this.

> rx_dropped -> software is dropping on purpose based on limits etc.
> 
> But I might be wrong.

rx-offload used this if the skb cannot be allocated.

Basically the kernel doc gives a general description of these values but
says: look at the driver for exact meaning :)

I wanted to keep it similar with the CAN drivers.

>> You can save the register access if you only check for overflows if
>> reading from the lowest prio mailbox.
>>
>> If you're discarding the data if the mailbox is marked as overflow
>> there's no need to read the data in the first place.
>>
> 
> Mind it that you don't cause a race! The bit can become set
> during reading of the data, it should be check _after_ we
> have a copy of the mailbox.

Right. My understanding of the bit was wrong.

In the flexcan HW there is a similar bit. It says there was an overflow
in this mailbox. But a coherence mechanism guarantees that the mailbox
is not changed by the CAN core, while the ARM accesses it.

> You can do a double check, one
> before one after, but since there should be no fifo overflow
> anyway, there is no reason to optimize for that path. (@250k
> I cannot get more then 3 messages in the fifo...).
Thanks for the explanations,
Marc

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


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

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

end of thread, other threads:[~2019-10-10 20:29 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 01/29] can: dev: add missing of_node_put() after calling of_get_child_by_name() Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 02/29] can: gs_usb: gs_can_open(): prevent memory leak Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 03/29] can: mcba_usb: fix use-after-free on disconnect Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 04/29] can: usb_8dev: " Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 05/29] can: flexcan: disable completely the ECC mechanism Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 06/29] can: peak_usb: fix a potential out-of-sync while decoding packets Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 07/29] can: peak_usb: report bus recovery as well Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 08/29] can: c_can: c_can_poll(): only read status register after status IRQ Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 09/29] can: c_can: D_CAN: c_can_chip_config(): perform a sofware reset on open Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 10/29] can: c_can: C_CAN: add bus recovery events Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 11/29] can: xilinx_can: Fix flags field initialization for axi can Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 12/29] can: rx-offload: can_rx_offload_queue_sorted(): fix error handling, avoid skb mem leak Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 13/29] can: rx-offload: can_rx_offload_queue_tail(): " Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 14/29] can: rx-offload: can_rx_offload_offload_one(): do not increase the skb_queue beyond skb_queue_len_max Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 15/29] can: rx-offload: can_rx_offload_offload_one(): increment rx_fifo_errors on queue overflow or OOM Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 16/29] can: rx-offload: can_rx_offload_offload_one(): use ERR_PTR() to propagate error value in case of errors Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 17/29] can: rx-offload: can_rx_offload_irq_offload_timestamp(): continue on error Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 18/29] can: rx-offload: can_rx_offload_irq_offload_fifo(): " Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 19/29] can: flexcan: increase error counters if skb enqueueing via can_rx_offload_queue_sorted() fails Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 20/29] can: ti_hecc: ti_hecc_error(): " Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 21/29] can: ti_hecc: ti_hecc_stop(): stop the CPK on down Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 22/29] can: ti_hecc: keep MIM and MD set Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 23/29] can: ti_hecc: release the mailbox a bit earlier Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 24/29] can: ti_hecc: add fifo underflow error reporting Marc Kleine-Budde
2019-10-10 15:52   ` Marc Kleine-Budde
2019-10-10 18:04     ` Jeroen Hofstee
     [not found]     ` <694ef4e8-166b-7eeb-4d6e-39a0ecacc93f@victronenergy.com>
2019-10-10 20:29       ` Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 25/29] can: ti_hecc: properly report state changes Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 26/29] can: ti_hecc: add missing " Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 27/29] can: j1939: fix resource leak of skb on error return paths Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 28/29] can: j1939: fix memory leak if filters was set Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 29/29] can: don't use deprecated license identifiers 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.