Netdev List
 help / color / mirror / Atom feed
* [PATCH 13/17] can: m_can: fix possible sleep in napi poll
From: Marc Kleine-Budde @ 2014-11-18 20:37 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-can, kernel, Dong Aisheng, Marc Kleine-Budde
In-Reply-To: <1416343067-9810-1-git-send-email-mkl@pengutronix.de>

From: Dong Aisheng <b29396@freescale.com>

The m_can_get_berr_counter function can sleep and it may be called in napi poll
function. Rework it to fix the following warning.

root@imx6qdlsolo:~# cangen can0 -f -L 12 -D 112233445566778899001122
[ 1846.017565] m_can 20e8000.can can0: entered error warning state
[ 1846.023551] ------------[ cut here ]------------
[ 1846.028216] WARNING: CPU: 0 PID: 560 at kernel/locking/mutex.c:867 mutex_trylock+0x218/0x23c()
[ 1846.036889] DEBUG_LOCKS_WARN_ON(in_interrupt())
[ 1846.041263] Modules linked in:
[ 1846.044594] CPU: 0 PID: 560 Comm: cangen Not tainted 3.17.0-rc4-next-20140915-00010-g032d018-dirty #477
[ 1846.054033] Backtrace:
[ 1846.056557] [<80012448>] (dump_backtrace) from [<80012728>] (show_stack+0x18/0x1c)
[ 1846.064180]  r6:809a07ec r5:809a07ec r4:00000000 r3:00000000
[ 1846.069966] [<80012710>] (show_stack) from [<806c9ee0>] (dump_stack+0x8c/0xa4)
[ 1846.077264] [<806c9e54>] (dump_stack) from [<8002aa78>] (warn_slowpath_common+0x70/0x94)
[ 1846.085403]  r6:806cd1b0 r5:00000009 r4:be1d5c20 r3:be07b0c0
[ 1846.091204] [<8002aa08>] (warn_slowpath_common) from [<8002aad4>] (warn_slowpath_fmt+0x38/0x40)
[ 1846.099951]  r8:8119106c r7:80515aa4 r6:be027000 r5:00000001 r4:809d1df4
[ 1846.106830] [<8002aaa0>] (warn_slowpath_fmt) from [<806cd1b0>] (mutex_trylock+0x218/0x23c)
[ 1846.115141]  r3:80851c88 r2:8084fb74
[ 1846.118804] [<806ccf98>] (mutex_trylock) from [<80515aa4>] (clk_prepare_lock+0x14/0xf4)
[ 1846.126859]  r8:00000040 r7:be1d5cec r6:be027000 r5:be255800 r4:be027000
[ 1846.133737] [<80515a90>] (clk_prepare_lock) from [<80517660>] (clk_prepare+0x14/0x2c)
[ 1846.141583]  r5:be255800 r4:be027000
[ 1846.145272] [<8051764c>] (clk_prepare) from [<8041ff14>] (m_can_get_berr_counter+0x20/0xd4)
[ 1846.153672]  r4:be255800 r3:be07b0c0
[ 1846.157325] [<8041fef4>] (m_can_get_berr_counter) from [<80420428>] (m_can_poll+0x310/0x8fc)
[ 1846.165809]  r7:bd4dc540 r6:00000744 r5:11300000 r4:be255800
[ 1846.171590] [<80420118>] (m_can_poll) from [<8056a468>] (net_rx_action+0xcc/0x1b4)
[ 1846.179204]  r10:00000101 r9:be255ebc r8:00000040 r7:be7c3208 r6:8097c100 r5:be7c3200
[ 1846.187192]  r4:0000012c
[ 1846.189779] [<8056a39c>] (net_rx_action) from [<8002deec>] (__do_softirq+0xfc/0x2c4)
[ 1846.197568]  r10:00000101 r9:8097c088 r8:00000003 r7:8097c080 r6:40000001 r5:8097c08c
[ 1846.205559]  r4:00000020
[ 1846.208144] [<8002ddf0>] (__do_softirq) from [<8002e194>] (do_softirq+0x7c/0x88)
[ 1846.215588]  r10:00000000 r9:bd516a60 r8:be18ce00 r7:00000000 r6:be255800 r5:8056c0ec
[ 1846.223578]  r4:60000093
[ 1846.226163] [<8002e118>] (do_softirq) from [<8002e288>] (__local_bh_enable_ip+0xe8/0x10c)
[ 1846.234386]  r4:00000200 r3:be1d4000
[ 1846.238036] [<8002e1a0>] (__local_bh_enable_ip) from [<8056c108>] (__dev_queue_xmit+0x314/0x6b0)
[ 1846.246868]  r6:be255800 r5:bd516a00 r4:00000000 r3:be07b0c0
[ 1846.252645] [<8056bdf4>] (__dev_queue_xmit) from [<8056c4b8>] (dev_queue_xmit+0x14/0x18)

Signed-off-by: Dong Aisheng <b29396@freescale.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/m_can/m_can.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 268ad5064c47..214160b4c314 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -481,11 +481,23 @@ static int m_can_handle_lec_err(struct net_device *dev,
 	return 1;
 }
 
+static int __m_can_get_berr_counter(const struct net_device *dev,
+				    struct can_berr_counter *bec)
+{
+	struct m_can_priv *priv = netdev_priv(dev);
+	unsigned int ecr;
+
+	ecr = m_can_read(priv, M_CAN_ECR);
+	bec->rxerr = (ecr & ECR_REC_MASK) >> ECR_REC_SHIFT;
+	bec->txerr = ecr & ECR_TEC_MASK;
+
+	return 0;
+}
+
 static int m_can_get_berr_counter(const struct net_device *dev,
 				  struct can_berr_counter *bec)
 {
 	struct m_can_priv *priv = netdev_priv(dev);
-	unsigned int ecr;
 	int err;
 
 	err = clk_prepare_enable(priv->hclk);
@@ -498,9 +510,7 @@ static int m_can_get_berr_counter(const struct net_device *dev,
 		return err;
 	}
 
-	ecr = m_can_read(priv, M_CAN_ECR);
-	bec->rxerr = (ecr & ECR_REC_MASK) >> ECR_REC_SHIFT;
-	bec->txerr = ecr & ECR_TEC_MASK;
+	__m_can_get_berr_counter(dev, bec);
 
 	clk_disable_unprepare(priv->cclk);
 	clk_disable_unprepare(priv->hclk);
@@ -544,7 +554,7 @@ static int m_can_handle_state_change(struct net_device *dev,
 	if (unlikely(!skb))
 		return 0;
 
-	m_can_get_berr_counter(dev, &bec);
+	__m_can_get_berr_counter(dev, &bec);
 
 	switch (new_state) {
 	case CAN_STATE_ERROR_ACTIVE:
-- 
2.1.3


^ permalink raw reply related

* [PATCH 14/17] can: m_can: fix not set can_dlc for remote frame
From: Marc Kleine-Budde @ 2014-11-18 20:37 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-can, kernel, Dong Aisheng, Marc Kleine-Budde
In-Reply-To: <1416343067-9810-1-git-send-email-mkl@pengutronix.de>

From: Dong Aisheng <b29396@freescale.com>

The original code missed to set the cf->can_dlc in the RTR case, so add it.

Signed-off-by: Dong Aisheng <b29396@freescale.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/m_can/m_can.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 214160b4c314..98f7e0ea7f6a 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -330,7 +330,7 @@ static void m_can_read_fifo(const struct net_device *dev, struct can_frame *cf,
 			    u32 rxfs)
 {
 	struct m_can_priv *priv = netdev_priv(dev);
-	u32 id, fgi;
+	u32 id, fgi, dlc;
 
 	/* calculate the fifo get index for where to read data */
 	fgi = (rxfs & RXFS_FGI_MASK) >> RXFS_FGI_OFF;
@@ -340,11 +340,12 @@ static void m_can_read_fifo(const struct net_device *dev, struct can_frame *cf,
 	else
 		cf->can_id = (id >> 18) & CAN_SFF_MASK;
 
+	dlc = m_can_fifo_read(priv, fgi, M_CAN_FIFO_DLC);
+	cf->can_dlc = get_can_dlc((dlc >> 16) & 0x0F);
+
 	if (id & RX_BUF_RTR) {
 		cf->can_id |= CAN_RTR_FLAG;
 	} else {
-		id = m_can_fifo_read(priv, fgi, M_CAN_FIFO_DLC);
-		cf->can_dlc = get_can_dlc((id >> 16) & 0x0F);
 		*(u32 *)(cf->data + 0) = m_can_fifo_read(priv, fgi,
 							 M_CAN_FIFO_DATA(0));
 		*(u32 *)(cf->data + 4) = m_can_fifo_read(priv, fgi,
-- 
2.1.3


^ permalink raw reply related

* [PATCH 15/17] can: m_can: add missing delay after setting CCCR_INIT bit
From: Marc Kleine-Budde @ 2014-11-18 20:37 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-can, kernel, Dong Aisheng, Marc Kleine-Budde
In-Reply-To: <1416343067-9810-1-git-send-email-mkl@pengutronix.de>

From: Dong Aisheng <b29396@freescale.com>

The spec mentions there may be a delay until the value written to INIT can be
read back due to the synchronization mechanism between the two clock domains.
But it does not indicate the exact clock cycles needed. The 5us delay is a
test value and seems ok.

Without the delay, CCCR.CCE bit may fail to be set and then the initialization
fail sometimes when do repeatly up and down.

Signed-off-by: Dong Aisheng <b29396@freescale.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/m_can/m_can.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 98f7e0ea7f6a..3ad7d88720b7 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -296,6 +296,7 @@ static inline void m_can_config_endisable(const struct m_can_priv *priv,
 	if (enable) {
 		/* enable m_can configuration */
 		m_can_write(priv, M_CAN_CCCR, cccr | CCCR_INIT);
+		udelay(5);
 		/* CCCR.CCE can only be set/reset while CCCR.INIT = '1' */
 		m_can_write(priv, M_CAN_CCCR, cccr | CCCR_INIT | CCCR_CCE);
 	} else {
-- 
2.1.3


^ permalink raw reply related

* [PATCH 16/17] can: m_can: fix incorrect error messages
From: Marc Kleine-Budde @ 2014-11-18 20:37 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-can, kernel, Dong Aisheng, Marc Kleine-Budde
In-Reply-To: <1416343067-9810-1-git-send-email-mkl@pengutronix.de>

From: Dong Aisheng <b29396@freescale.com>

Fix a few error messages.

Signed-off-by: Dong Aisheng <b29396@freescale.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/m_can/m_can.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 3ad7d88720b7..2f61676b3a97 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -608,14 +608,14 @@ static int m_can_handle_state_errors(struct net_device *dev, u32 psr)
 
 	if ((psr & PSR_EP) &&
 	    (priv->can.state != CAN_STATE_ERROR_PASSIVE)) {
-		netdev_dbg(dev, "entered error warning state\n");
+		netdev_dbg(dev, "entered error passive state\n");
 		work_done += m_can_handle_state_change(dev,
 						       CAN_STATE_ERROR_PASSIVE);
 	}
 
 	if ((psr & PSR_BO) &&
 	    (priv->can.state != CAN_STATE_BUS_OFF)) {
-		netdev_dbg(dev, "entered error warning state\n");
+		netdev_dbg(dev, "entered error bus off state\n");
 		work_done += m_can_handle_state_change(dev,
 						       CAN_STATE_BUS_OFF);
 	}
@@ -627,7 +627,7 @@ static void m_can_handle_other_err(struct net_device *dev, u32 irqstatus)
 {
 	if (irqstatus & IR_WDI)
 		netdev_err(dev, "Message RAM Watchdog event due to missing READY\n");
-	if (irqstatus & IR_BEU)
+	if (irqstatus & IR_ELO)
 		netdev_err(dev, "Error Logging Overflow\n");
 	if (irqstatus & IR_BEU)
 		netdev_err(dev, "Bit Error Uncorrected\n");
-- 
2.1.3


^ permalink raw reply related

* [PATCH 17/17] can: m_can: update to support CAN FD features
From: Marc Kleine-Budde @ 2014-11-18 20:37 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-can, kernel, Dong Aisheng, Marc Kleine-Budde
In-Reply-To: <1416343067-9810-1-git-send-email-mkl@pengutronix.de>

From: Dong Aisheng <b29396@freescale.com>

Bosch M_CAN is CAN FD capable device. This patch implements the CAN
FD features include up to 64 bytes payload and bitrate switch function.
1) Change the Rx FIFO and Tx Buffer to 64 bytes for support CAN FD
   up to 64 bytes payload. It's backward compatible with old 8 bytes
   normal CAN frame.
2) Allocate can frame or canfd frame based on EDL bit
3) Bitrate Switch function is disabled by default and will be enabled
   according to CANFD_BRS bit in cf->flags.

Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Dong Aisheng <b29396@freescale.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/m_can/m_can.c | 177 ++++++++++++++++++++++++++++++++----------
 1 file changed, 134 insertions(+), 43 deletions(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 2f61676b3a97..d7bc462aafdc 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -105,14 +105,36 @@ enum m_can_mram_cfg {
 	MRAM_CFG_NUM,
 };
 
+/* Fast Bit Timing & Prescaler Register (FBTP) */
+#define FBTR_FBRP_MASK		0x1f
+#define FBTR_FBRP_SHIFT		16
+#define FBTR_FTSEG1_SHIFT	8
+#define FBTR_FTSEG1_MASK	(0xf << FBTR_FTSEG1_SHIFT)
+#define FBTR_FTSEG2_SHIFT	4
+#define FBTR_FTSEG2_MASK	(0x7 << FBTR_FTSEG2_SHIFT)
+#define FBTR_FSJW_SHIFT		0
+#define FBTR_FSJW_MASK		0x3
+
 /* Test Register (TEST) */
 #define TEST_LBCK	BIT(4)
 
 /* CC Control Register(CCCR) */
-#define CCCR_TEST	BIT(7)
-#define CCCR_MON	BIT(5)
-#define CCCR_CCE	BIT(1)
-#define CCCR_INIT	BIT(0)
+#define CCCR_TEST		BIT(7)
+#define CCCR_CMR_MASK		0x3
+#define CCCR_CMR_SHIFT		10
+#define CCCR_CMR_CANFD		0x1
+#define CCCR_CMR_CANFD_BRS	0x2
+#define CCCR_CMR_CAN		0x3
+#define CCCR_CME_MASK		0x3
+#define CCCR_CME_SHIFT		8
+#define CCCR_CME_CAN		0
+#define CCCR_CME_CANFD		0x1
+#define CCCR_CME_CANFD_BRS	0x2
+#define CCCR_TEST		BIT(7)
+#define CCCR_MON		BIT(5)
+#define CCCR_CCE		BIT(1)
+#define CCCR_INIT		BIT(0)
+#define CCCR_CANFD		0x10
 
 /* Bit Timing & Prescaler Register (BTP) */
 #define BTR_BRP_MASK		0x3ff
@@ -204,6 +226,7 @@ enum m_can_mram_cfg {
 
 /* Rx Buffer / FIFO Element Size Configuration (RXESC) */
 #define M_CAN_RXESC_8BYTES	0x0
+#define M_CAN_RXESC_64BYTES	0x777
 
 /* Tx Buffer Configuration(TXBC) */
 #define TXBC_NDTB_OFF		16
@@ -211,6 +234,7 @@ enum m_can_mram_cfg {
 
 /* Tx Buffer Element Size Configuration(TXESC) */
 #define TXESC_TBDS_8BYTES	0x0
+#define TXESC_TBDS_64BYTES	0x7
 
 /* Tx Event FIFO Con.guration (TXEFC) */
 #define TXEFC_EFS_OFF		16
@@ -219,11 +243,11 @@ enum m_can_mram_cfg {
 /* Message RAM Configuration (in bytes) */
 #define SIDF_ELEMENT_SIZE	4
 #define XIDF_ELEMENT_SIZE	8
-#define RXF0_ELEMENT_SIZE	16
-#define RXF1_ELEMENT_SIZE	16
+#define RXF0_ELEMENT_SIZE	72
+#define RXF1_ELEMENT_SIZE	72
 #define RXB_ELEMENT_SIZE	16
 #define TXE_ELEMENT_SIZE	8
-#define TXB_ELEMENT_SIZE	16
+#define TXB_ELEMENT_SIZE	72
 
 /* Message RAM Elements */
 #define M_CAN_FIFO_ID		0x0
@@ -231,11 +255,17 @@ enum m_can_mram_cfg {
 #define M_CAN_FIFO_DATA(n)	(0x8 + ((n) << 2))
 
 /* Rx Buffer Element */
+/* R0 */
 #define RX_BUF_ESI		BIT(31)
 #define RX_BUF_XTD		BIT(30)
 #define RX_BUF_RTR		BIT(29)
+/* R1 */
+#define RX_BUF_ANMF		BIT(31)
+#define RX_BUF_EDL		BIT(21)
+#define RX_BUF_BRS		BIT(20)
 
 /* Tx Buffer Element */
+/* R0 */
 #define TX_BUF_XTD		BIT(30)
 #define TX_BUF_RTR		BIT(29)
 
@@ -327,42 +357,67 @@ static inline void m_can_disable_all_interrupts(const struct m_can_priv *priv)
 	m_can_write(priv, M_CAN_ILE, 0x0);
 }
 
-static void m_can_read_fifo(const struct net_device *dev, struct can_frame *cf,
-			    u32 rxfs)
+static void m_can_read_fifo(struct net_device *dev, u32 rxfs)
 {
+	struct net_device_stats *stats = &dev->stats;
 	struct m_can_priv *priv = netdev_priv(dev);
+	struct canfd_frame *cf;
+	struct sk_buff *skb;
 	u32 id, fgi, dlc;
+	int i;
 
 	/* calculate the fifo get index for where to read data */
 	fgi = (rxfs & RXFS_FGI_MASK) >> RXFS_FGI_OFF;
+	dlc = m_can_fifo_read(priv, fgi, M_CAN_FIFO_DLC);
+	if (dlc & RX_BUF_EDL)
+		skb = alloc_canfd_skb(dev, &cf);
+	else
+		skb = alloc_can_skb(dev, (struct can_frame **)&cf);
+	if (!skb) {
+		stats->rx_dropped++;
+		return;
+	}
+
+	if (dlc & RX_BUF_EDL)
+		cf->len = can_dlc2len((dlc >> 16) & 0x0F);
+	else
+		cf->len = get_can_dlc((dlc >> 16) & 0x0F);
+
 	id = m_can_fifo_read(priv, fgi, M_CAN_FIFO_ID);
 	if (id & RX_BUF_XTD)
 		cf->can_id = (id & CAN_EFF_MASK) | CAN_EFF_FLAG;
 	else
 		cf->can_id = (id >> 18) & CAN_SFF_MASK;
 
-	dlc = m_can_fifo_read(priv, fgi, M_CAN_FIFO_DLC);
-	cf->can_dlc = get_can_dlc((dlc >> 16) & 0x0F);
+	if (id & RX_BUF_ESI) {
+		cf->flags |= CANFD_ESI;
+		netdev_dbg(dev, "ESI Error\n");
+	}
 
-	if (id & RX_BUF_RTR) {
+	if (!(dlc & RX_BUF_EDL) && (id & RX_BUF_RTR)) {
 		cf->can_id |= CAN_RTR_FLAG;
 	} else {
-		*(u32 *)(cf->data + 0) = m_can_fifo_read(priv, fgi,
-							 M_CAN_FIFO_DATA(0));
-		*(u32 *)(cf->data + 4) = m_can_fifo_read(priv, fgi,
-							 M_CAN_FIFO_DATA(1));
+		if (dlc & RX_BUF_BRS)
+			cf->flags |= CANFD_BRS;
+
+		for (i = 0; i < cf->len; i += 4)
+			*(u32 *)(cf->data + i) =
+				m_can_fifo_read(priv, fgi,
+						M_CAN_FIFO_DATA(i / 4));
 	}
 
 	/* acknowledge rx fifo 0 */
 	m_can_write(priv, M_CAN_RXF0A, fgi);
+
+	stats->rx_packets++;
+	stats->rx_bytes += cf->len;
+
+	netif_receive_skb(skb);
 }
 
 static int m_can_do_rx_poll(struct net_device *dev, int quota)
 {
 	struct m_can_priv *priv = netdev_priv(dev);
-	struct net_device_stats *stats = &dev->stats;
-	struct sk_buff *skb;
-	struct can_frame *frame;
 	u32 pkts = 0;
 	u32 rxfs;
 
@@ -376,18 +431,7 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota)
 		if (rxfs & RXFS_RFL)
 			netdev_warn(dev, "Rx FIFO 0 Message Lost\n");
 
-		skb = alloc_can_skb(dev, &frame);
-		if (!skb) {
-			stats->rx_dropped++;
-			return pkts;
-		}
-
-		m_can_read_fifo(dev, frame, rxfs);
-
-		stats->rx_packets++;
-		stats->rx_bytes += frame->can_dlc;
-
-		netif_receive_skb(skb);
+		m_can_read_fifo(dev, rxfs);
 
 		quota--;
 		pkts++;
@@ -745,10 +789,23 @@ static const struct can_bittiming_const m_can_bittiming_const = {
 	.brp_inc = 1,
 };
 
+static const struct can_bittiming_const m_can_data_bittiming_const = {
+	.name = KBUILD_MODNAME,
+	.tseg1_min = 2,		/* Time segment 1 = prop_seg + phase_seg1 */
+	.tseg1_max = 16,
+	.tseg2_min = 1,		/* Time segment 2 = phase_seg2 */
+	.tseg2_max = 8,
+	.sjw_max = 4,
+	.brp_min = 1,
+	.brp_max = 32,
+	.brp_inc = 1,
+};
+
 static int m_can_set_bittiming(struct net_device *dev)
 {
 	struct m_can_priv *priv = netdev_priv(dev);
 	const struct can_bittiming *bt = &priv->can.bittiming;
+	const struct can_bittiming *dbt = &priv->can.data_bittiming;
 	u16 brp, sjw, tseg1, tseg2;
 	u32 reg_btp;
 
@@ -759,7 +816,17 @@ static int m_can_set_bittiming(struct net_device *dev)
 	reg_btp = (brp << BTR_BRP_SHIFT) | (sjw << BTR_SJW_SHIFT) |
 			(tseg1 << BTR_TSEG1_SHIFT) | (tseg2 << BTR_TSEG2_SHIFT);
 	m_can_write(priv, M_CAN_BTP, reg_btp);
-	netdev_dbg(dev, "setting BTP 0x%x\n", reg_btp);
+
+	if (priv->can.ctrlmode & CAN_CTRLMODE_FD) {
+		brp = dbt->brp - 1;
+		sjw = dbt->sjw - 1;
+		tseg1 = dbt->prop_seg + dbt->phase_seg1 - 1;
+		tseg2 = dbt->phase_seg2 - 1;
+		reg_btp = (brp << FBTR_FBRP_SHIFT) | (sjw << FBTR_FSJW_SHIFT) |
+				(tseg1 << FBTR_FTSEG1_SHIFT) |
+				(tseg2 << FBTR_FTSEG2_SHIFT);
+		m_can_write(priv, M_CAN_FBTP, reg_btp);
+	}
 
 	return 0;
 }
@@ -779,8 +846,8 @@ static void m_can_chip_config(struct net_device *dev)
 
 	m_can_config_endisable(priv, true);
 
-	/* RX Buffer/FIFO Element Size 8 bytes data field */
-	m_can_write(priv, M_CAN_RXESC, M_CAN_RXESC_8BYTES);
+	/* RX Buffer/FIFO Element Size 64 bytes data field */
+	m_can_write(priv, M_CAN_RXESC, M_CAN_RXESC_64BYTES);
 
 	/* Accept Non-matching Frames Into FIFO 0 */
 	m_can_write(priv, M_CAN_GFC, 0x0);
@@ -789,8 +856,8 @@ static void m_can_chip_config(struct net_device *dev)
 	m_can_write(priv, M_CAN_TXBC, (1 << TXBC_NDTB_OFF) |
 		    priv->mcfg[MRAM_TXB].off);
 
-	/* only support 8 bytes firstly */
-	m_can_write(priv, M_CAN_TXESC, TXESC_TBDS_8BYTES);
+	/* support 64 bytes payload */
+	m_can_write(priv, M_CAN_TXESC, TXESC_TBDS_64BYTES);
 
 	m_can_write(priv, M_CAN_TXEFC, (1 << TXEFC_EFS_OFF) |
 		    priv->mcfg[MRAM_TXE].off);
@@ -805,7 +872,8 @@ static void m_can_chip_config(struct net_device *dev)
 		    RXFC_FWM_1 | priv->mcfg[MRAM_RXF1].off);
 
 	cccr = m_can_read(priv, M_CAN_CCCR);
-	cccr &= ~(CCCR_TEST | CCCR_MON);
+	cccr &= ~(CCCR_TEST | CCCR_MON | (CCCR_CMR_MASK << CCCR_CMR_SHIFT) |
+		(CCCR_CME_MASK << CCCR_CME_SHIFT));
 	test = m_can_read(priv, M_CAN_TEST);
 	test &= ~TEST_LBCK;
 
@@ -817,6 +885,9 @@ static void m_can_chip_config(struct net_device *dev)
 		test |= TEST_LBCK;
 	}
 
+	if (priv->can.ctrlmode & CAN_CTRLMODE_FD)
+		cccr |= CCCR_CME_CANFD_BRS << CCCR_CME_SHIFT;
+
 	m_can_write(priv, M_CAN_CCCR, cccr);
 	m_can_write(priv, M_CAN_TEST, test);
 
@@ -881,11 +952,13 @@ static struct net_device *alloc_m_can_dev(void)
 
 	priv->dev = dev;
 	priv->can.bittiming_const = &m_can_bittiming_const;
+	priv->can.data_bittiming_const = &m_can_data_bittiming_const;
 	priv->can.do_set_mode = m_can_set_mode;
 	priv->can.do_get_berr_counter = m_can_get_berr_counter;
 	priv->can.ctrlmode_supported = CAN_CTRLMODE_LOOPBACK |
 					CAN_CTRLMODE_LISTENONLY |
-					CAN_CTRLMODE_BERR_REPORTING;
+					CAN_CTRLMODE_BERR_REPORTING |
+					CAN_CTRLMODE_FD;
 
 	return dev;
 }
@@ -968,8 +1041,9 @@ static netdev_tx_t m_can_start_xmit(struct sk_buff *skb,
 				    struct net_device *dev)
 {
 	struct m_can_priv *priv = netdev_priv(dev);
-	struct can_frame *cf = (struct can_frame *)skb->data;
-	u32 id;
+	struct canfd_frame *cf = (struct canfd_frame *)skb->data;
+	u32 id, cccr;
+	int i;
 
 	if (can_dropped_invalid_skb(dev, skb))
 		return NETDEV_TX_OK;
@@ -988,11 +1062,28 @@ static netdev_tx_t m_can_start_xmit(struct sk_buff *skb,
 
 	/* message ram configuration */
 	m_can_fifo_write(priv, 0, M_CAN_FIFO_ID, id);
-	m_can_fifo_write(priv, 0, M_CAN_FIFO_DLC, cf->can_dlc << 16);
-	m_can_fifo_write(priv, 0, M_CAN_FIFO_DATA(0), *(u32 *)(cf->data + 0));
-	m_can_fifo_write(priv, 0, M_CAN_FIFO_DATA(1), *(u32 *)(cf->data + 4));
+	m_can_fifo_write(priv, 0, M_CAN_FIFO_DLC, can_len2dlc(cf->len) << 16);
+
+	for (i = 0; i < cf->len; i += 4)
+		m_can_fifo_write(priv, 0, M_CAN_FIFO_DATA(i / 4),
+				 *(u32 *)(cf->data + i));
+
 	can_put_echo_skb(skb, dev, 0);
 
+	if (priv->can.ctrlmode & CAN_CTRLMODE_FD) {
+		cccr = m_can_read(priv, M_CAN_CCCR);
+		cccr &= ~(CCCR_CMR_MASK << CCCR_CMR_SHIFT);
+		if (can_is_canfd_skb(skb)) {
+			if (cf->flags & CANFD_BRS)
+				cccr |= CCCR_CMR_CANFD_BRS << CCCR_CMR_SHIFT;
+			else
+				cccr |= CCCR_CMR_CANFD << CCCR_CMR_SHIFT;
+		} else {
+			cccr |= CCCR_CMR_CAN << CCCR_CMR_SHIFT;
+		}
+		m_can_write(priv, M_CAN_CCCR, cccr);
+	}
+
 	/* enable first TX buffer to start transfer  */
 	m_can_write(priv, M_CAN_TXBTIE, 0x1);
 	m_can_write(priv, M_CAN_TXBAR, 0x1);
-- 
2.1.3


^ permalink raw reply related

* [PATCH 01/17] can: dev: avoid calling kfree_skb() from interrupt context
From: Marc Kleine-Budde @ 2014-11-18 20:37 UTC (permalink / raw)
  To: netdev
  Cc: davem, linux-can, kernel, Thomas Körper, linux-stable,
	Marc Kleine-Budde
In-Reply-To: <1416343067-9810-1-git-send-email-mkl@pengutronix.de>

From: Thomas Körper <thomas.koerper@esd.eu>

ikfree_skb() is Called in can_free_echo_skb(), which might be called from (TX
Error) interrupt, which triggers the folloing warning:

[ 1153.360705] ------------[ cut here ]------------
[ 1153.360715] WARNING: CPU: 0 PID: 31 at net/core/skbuff.c:563 skb_release_head_state+0xb9/0xd0()
[ 1153.360772] Call Trace:
[ 1153.360778]  [<c167906f>] dump_stack+0x41/0x52
[ 1153.360782]  [<c105bb7e>] warn_slowpath_common+0x7e/0xa0
[ 1153.360784]  [<c158b909>] ? skb_release_head_state+0xb9/0xd0
[ 1153.360786]  [<c158b909>] ? skb_release_head_state+0xb9/0xd0
[ 1153.360788]  [<c105bc42>] warn_slowpath_null+0x22/0x30
[ 1153.360791]  [<c158b909>] skb_release_head_state+0xb9/0xd0
[ 1153.360793]  [<c158be90>] skb_release_all+0x10/0x30
[ 1153.360795]  [<c158bf06>] kfree_skb+0x36/0x80
[ 1153.360799]  [<f8486938>] ? can_free_echo_skb+0x28/0x40 [can_dev]
[ 1153.360802]  [<f8486938>] can_free_echo_skb+0x28/0x40 [can_dev]
[ 1153.360805]  [<f849a12c>] esd_pci402_interrupt+0x34c/0x57a [esd402]
[ 1153.360809]  [<c10a75b5>] handle_irq_event_percpu+0x35/0x180
[ 1153.360811]  [<c10a7623>] ? handle_irq_event_percpu+0xa3/0x180
[ 1153.360813]  [<c10a7731>] handle_irq_event+0x31/0x50
[ 1153.360816]  [<c10a9c7f>] handle_fasteoi_irq+0x6f/0x120
[ 1153.360818]  [<c10a9c10>] ? handle_edge_irq+0x110/0x110
[ 1153.360822]  [<c1011b61>] handle_irq+0x71/0x90
[ 1153.360823]  <IRQ>  [<c168152c>] do_IRQ+0x3c/0xd0
[ 1153.360829]  [<c1680b6c>] common_interrupt+0x2c/0x34
[ 1153.360834]  [<c107d277>] ? finish_task_switch+0x47/0xf0
[ 1153.360836]  [<c167c27b>] __schedule+0x35b/0x7e0
[ 1153.360839]  [<c10a5334>] ? console_unlock+0x2c4/0x4d0
[ 1153.360842]  [<c13df500>] ? n_tty_receive_buf_common+0x890/0x890
[ 1153.360845]  [<c10707b6>] ? process_one_work+0x196/0x370
[ 1153.360847]  [<c167c723>] schedule+0x23/0x60
[ 1153.360849]  [<c1070de1>] worker_thread+0x161/0x460
[ 1153.360852]  [<c1090fcf>] ? __wake_up_locked+0x1f/0x30
[ 1153.360854]  [<c1070c80>] ? rescuer_thread+0x2f0/0x2f0
[ 1153.360856]  [<c1074f01>] kthread+0xa1/0xc0
[ 1153.360859]  [<c1680401>] ret_from_kernel_thread+0x21/0x30
[ 1153.360861]  [<c1074e60>] ? kthread_create_on_node+0x110/0x110
[ 1153.360863] ---[ end trace 5ff83639cbb74b35 ]---

This patch replaces the kfree_skb() by dev_kfree_skb_any().

Signed-off-by: Thomas Körper <thomas.koerper@esd.eu>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index 02492d241e4c..509d5e063d8c 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -382,7 +382,7 @@ void can_free_echo_skb(struct net_device *dev, unsigned int idx)
 	BUG_ON(idx >= priv->echo_skb_max);
 
 	if (priv->echo_skb[idx]) {
-		kfree_skb(priv->echo_skb[idx]);
+		dev_kfree_skb_any(priv->echo_skb[idx]);
 		priv->echo_skb[idx] = NULL;
 	}
 }
-- 
2.1.3

^ permalink raw reply related

* [PATCH 03/17] can: dev: add can_is_canfd_skb() API
From: Marc Kleine-Budde @ 2014-11-18 20:37 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-can, kernel, Dong Aisheng, Marc Kleine-Budde
In-Reply-To: <1416343067-9810-1-git-send-email-mkl@pengutronix.de>

From: Dong Aisheng <b29396@freescale.com>

The CAN device drivers can use can_is_canfd_skb() to check if the frame to send
is on CAN FD mode or normal CAN mode.

Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Dong Aisheng <b29396@freescale.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 include/linux/can/dev.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h
index 6992afc6ba7f..b37ea95bc348 100644
--- a/include/linux/can/dev.h
+++ b/include/linux/can/dev.h
@@ -99,6 +99,12 @@ inval_skb:
 	return 1;
 }
 
+static inline bool can_is_canfd_skb(const struct sk_buff *skb)
+{
+	/* the CAN specific type of skb is identified by its data length */
+	return skb->len == CANFD_MTU;
+}
+
 /* get data length from can_dlc with sanitized can_dlc */
 u8 can_dlc2len(u8 can_dlc);
 
-- 
2.1.3

^ permalink raw reply related

* [PATCH 04/17] can: esd_usb2: fix memory leak on disconnect
From: Marc Kleine-Budde @ 2014-11-18 20:37 UTC (permalink / raw)
  To: netdev
  Cc: davem, linux-can, kernel, Alexey Khoroshilov, linux-stable,
	Marc Kleine-Budde
In-Reply-To: <1416343067-9810-1-git-send-email-mkl@pengutronix.de>

From: Alexey Khoroshilov <khoroshilov@ispras.ru>

It seems struct esd_usb2 dev is not deallocated on disconnect. The patch adds
the missing deallocation.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Acked-by: Matthias Fuchs <matthias.fuchs@esd.eu>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/esd_usb2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/can/usb/esd_usb2.c b/drivers/net/can/usb/esd_usb2.c
index b7c9e8b11460..7a90075529c3 100644
--- a/drivers/net/can/usb/esd_usb2.c
+++ b/drivers/net/can/usb/esd_usb2.c
@@ -1143,6 +1143,7 @@ static void esd_usb2_disconnect(struct usb_interface *intf)
 			}
 		}
 		unlink_all_urbs(dev);
+		kfree(dev);
 	}
 }
 
-- 
2.1.3

^ permalink raw reply related

* [PATCH 06/17] can: xilinx_can: fix comparison of unsigned variable
From: Marc Kleine-Budde @ 2014-11-18 20:37 UTC (permalink / raw)
  To: netdev
  Cc: davem, linux-can, kernel, Sudip Mukherjee, Sudip Mukherjee,
	Marc Kleine-Budde
In-Reply-To: <1416343067-9810-1-git-send-email-mkl@pengutronix.de>

From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>

The variable err was of the type u32. It was being compared with < 0, and being
an unsigned variable the comparison would have been always false.

Moreover, err was getting the return value from set_reset_mode() and
xcan_set_bittiming(), and both are returning int.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Reviewed-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/xilinx_can.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c
index 5e8b5609c067..47b2f801d127 100644
--- a/drivers/net/can/xilinx_can.c
+++ b/drivers/net/can/xilinx_can.c
@@ -300,7 +300,8 @@ static int xcan_set_bittiming(struct net_device *ndev)
 static int xcan_chip_start(struct net_device *ndev)
 {
 	struct xcan_priv *priv = netdev_priv(ndev);
-	u32 err, reg_msr, reg_sr_mask;
+	u32 reg_msr, reg_sr_mask;
+	int err;
 	unsigned long timeout;
 
 	/* Check if it is in reset mode */
-- 
2.1.3

^ permalink raw reply related

* [PATCH 07/17] can: xilinx_can: add .ndo_change_mtu function
From: Marc Kleine-Budde @ 2014-11-18 20:37 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-can, kernel, Marc Kleine-Budde
In-Reply-To: <1416343067-9810-1-git-send-email-mkl@pengutronix.de>

Use common can_change_mtu function.

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

diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c
index 47b2f801d127..8a998e3884ce 100644
--- a/drivers/net/can/xilinx_can.c
+++ b/drivers/net/can/xilinx_can.c
@@ -962,6 +962,7 @@ static const struct net_device_ops xcan_netdev_ops = {
 	.ndo_open	= xcan_open,
 	.ndo_stop	= xcan_close,
 	.ndo_start_xmit	= xcan_start_xmit,
+	.ndo_change_mtu	= can_change_mtu,
 };
 
 /**
-- 
2.1.3

^ permalink raw reply related

* [PATCH 08/17] can: rcar_can: add .ndo_change_mtu function
From: Marc Kleine-Budde @ 2014-11-18 20:37 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-can, kernel, Marc Kleine-Budde
In-Reply-To: <1416343067-9810-1-git-send-email-mkl@pengutronix.de>

Use common can_change_mtu function.

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

diff --git a/drivers/net/can/rcar_can.c b/drivers/net/can/rcar_can.c
index 1abe133d1594..9718248e55f1 100644
--- a/drivers/net/can/rcar_can.c
+++ b/drivers/net/can/rcar_can.c
@@ -628,6 +628,7 @@ static const struct net_device_ops rcar_can_netdev_ops = {
 	.ndo_open = rcar_can_open,
 	.ndo_stop = rcar_can_close,
 	.ndo_start_xmit = rcar_can_start_xmit,
+	.ndo_change_mtu = can_change_mtu,
 };
 
 static void rcar_can_rx_pkt(struct rcar_can_priv *priv)
-- 
2.1.3

^ permalink raw reply related

* [PATCH 09/17] can: gs_usb: add .ndo_change_mtu function
From: Marc Kleine-Budde @ 2014-11-18 20:37 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-can, kernel, Marc Kleine-Budde
In-Reply-To: <1416343067-9810-1-git-send-email-mkl@pengutronix.de>

Use common can_change_mtu function.

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 04b0f84612f0..009acc8641fc 100644
--- a/drivers/net/can/usb/gs_usb.c
+++ b/drivers/net/can/usb/gs_usb.c
@@ -718,6 +718,7 @@ static const struct net_device_ops gs_usb_netdev_ops = {
 	.ndo_open = gs_can_open,
 	.ndo_stop = gs_can_close,
 	.ndo_start_xmit = gs_can_start_xmit,
+	.ndo_change_mtu = can_change_mtu,
 };
 
 static struct gs_can *gs_make_candev(unsigned int channel, struct usb_interface *intf)
-- 
2.1.3

^ permalink raw reply related

* Re: [PATCH 1/2] net: can: remove unused variable
From: Marc Kleine-Budde @ 2014-11-18 20:39 UTC (permalink / raw)
  To: Sudip Mukherjee, Wolfgang Grandegger; +Cc: linux-can, netdev, linux-kernel
In-Reply-To: <1416318427-28676-1-git-send-email-sudipm.mukherjee@gmail.com>

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

On 11/18/2014 02:47 PM, Sudip Mukherjee wrote:
> these variable were only assigned some values, but then never
> reused again.
> so they are safe to be removed.

Thanks, I've applied both patches.

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: 819 bytes --]

^ permalink raw reply

* Re: Question about Patch Submissions
From: rapier @ 2014-11-18 20:39 UTC (permalink / raw)
  To: Cong Wang; +Cc: netdev
In-Reply-To: <CAHA+R7P-G4P-AzTM248FqNEm=dcuQOB_fwdM0Us3gsQgSeY0UQ@mail.gmail.com>

Cong,

Thanks for the response.

It's a pretty extensive patch set and we're trying to make sure it makes 
sense in context. It touches quite a few files and they're mostly 
interdependent. That's why we're having problems trying to figure out 
how to break this down for presentation. We can make sure each section 
of the patch applies cleanly but the entirety of the patch set would 
have to be applied for it to compile.

Chris

On 11/18/14, 3:21 PM, Cong Wang wrote:
> On Tue, Nov 18, 2014 at 11:13 AM, rapier <rapier@psc.edu> wrote:
>> I've read the documentation I've been able to find on the patch submission
>> process. I was hoping to clarify one thing though. When submitting a patch
>> that spans multiple files and functions is it better to break the submission
>> down by function or by file?
>>
>
> It depends on what you change, if your patch is trivial, say just cleaning up
> whitespaces, or a big single patch doesn't harm review, it is okay not
> to split it.
> Otherwise, probably you need to split it logically, each of which needs to at
> least compile.
>

^ permalink raw reply

* Re: [PATCH v2 net-next 0/7] implementation of eBPF maps
From: David Miller @ 2014-11-18 20:39 UTC (permalink / raw)
  To: ast-uqk4Ao+rVK5Wk0Htik3J/w
  Cc: mingo-DgEjT+Ai2ygdnm+yROfE0A, luto-kltTT9wpgjJwATOyAt5JVQ,
	dborkman-H+wXaHxf7aLQT0dZR+AlfA,
	hannes-tFNcAqjVMyqKXQKiL6tip0B+6BGkLq7r,
	edumazet-hpIqsD4AKlfQT0dZR+AlfA, linux-api-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1415929010-9361-1-git-send-email-ast-uqk4Ao+rVK5Wk0Htik3J/w@public.gmane.org>

From: Alexei Starovoitov <ast-uqk4Ao+rVK5Wk0Htik3J/w@public.gmane.org>
Date: Thu, 13 Nov 2014 17:36:43 -0800

> v1->v2:
> renamed flags for MAP_UPDATE_ELEM command to be more concise,
> clarified commit logs and improved comments in patches 1,3,7
> per discussions with Daniel
>  
> Old v1 cover:
> 
> this set of patches adds implementation of HASH and ARRAY types of eBPF maps
> which were described in manpage in commit b4fc1a460f30("Merge branch 'bpf-next'")
> 
> The difference vs previous version of these patches from August:
> - added 'flags' attribute to BPF_MAP_UPDATE_ELEM
> - in HASH type implementation removed per-map kmem_cache.
>   I was doing kmem_cache_create() for every map to enable selective slub
>   debugging to check for overflows and leaks. Now it's not needed, so just
>   use normal kmalloc() for map elements.
> - added ARRAY type which was mentioned in manpage, but wasn't public yet
> - added map testsuite and removed temporary bits from test_stubs
> 
> Note, eBPF programs cannot be attached to events yet.
> It will come in the next set.

Series applied, thanks Alexei.

^ permalink raw reply

* Re: [PATCH V5 1/2] can: m_can: fix not set can_dlc for remote frame
From: Marc Kleine-Budde @ 2014-11-18 20:40 UTC (permalink / raw)
  To: Dong Aisheng, linux-can
  Cc: wg, varkabhadram, netdev, socketcan, linux-arm-kernel
In-Reply-To: <1416308455-29134-1-git-send-email-b29396@freescale.com>

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

On 11/18/2014 12:00 PM, Dong Aisheng wrote:
> The original code missed to set the cf->can_dlc in the RTR case, so add it.

Applied both patches. Let's see what David says to the CAN FD support.

Thanks,
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: 819 bytes --]

^ permalink raw reply

* [PATCH 1/1] net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"
From: SF Markus Elfring @ 2014-11-18 20:45 UTC (permalink / raw)
  To: David S. Miller, Herbert Xu, Steffen Klassert, netdev
  Cc: LKML, kernel-janitors, Coccinelle
In-Reply-To: <5317A59D.4@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 21:41:26 +0100

The ipcomp_free_tfms() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/xfrm/xfrm_ipcomp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c
index ccfdc71..47863cd 100644
--- a/net/xfrm/xfrm_ipcomp.c
+++ b/net/xfrm/xfrm_ipcomp.c
@@ -320,8 +320,7 @@ error:
 
 static void ipcomp_free_data(struct ipcomp_data *ipcd)
 {
-	if (ipcd->tfms)
-		ipcomp_free_tfms(ipcd->tfms);
+	ipcomp_free_tfms(ipcd->tfms);
 	ipcomp_free_scratches();
 }
 
-- 
2.1.3

^ permalink raw reply related

* Re: [PATCH net-next] netdevice: Neaten includes and forward declarations
From: David Miller @ 2014-11-18 20:48 UTC (permalink / raw)
  To: joe; +Cc: netdev
In-Reply-To: <1416176491.24600.3.camel@perches.com>

From: Joe Perches <joe@perches.com>
Date: Sun, 16 Nov 2014 14:21:31 -0800

> Use the appropriate #include path for neighbour.h and
> add device.h which was indirectly #included by dmaengine.h
> 
> Remove unnecessary forward declaration of struct device;
> 
> Add comments for other forward struct declarations.
> 
> Signed-off-by: Joe Perches <joe@perches.com>

This no longer applies to net-next, please respin.

Thanks.

^ permalink raw reply

* Re: [patch iproute2] tc: add support for vlan tc action
From: Jiri Pirko @ 2014-11-18 20:48 UTC (permalink / raw)
  To: Jamal Hadi Salim
  Cc: netdev, davem, pshelar, therbert, edumazet, willemb, dborkman,
	mst, fw, Paul.Durrant, tgraf
In-Reply-To: <546906D6.7040400@mojatatu.com>

Sun, Nov 16, 2014 at 09:19:34PM CET, jhs@mojatatu.com wrote:
>On 11/12/14 09:55, Jiri Pirko wrote:
>>Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
>>Signed-off-by: Jiri Pirko <jiri@resnulli.us>
>>
>
>Latest patches work great. If you want you can
>include these notes in the iproute2 commit log.
>
>There is only one small doubt when i add two vlan
>tags(Q followed by QandQ). Look at the very end
>of the text i have below...

I fixed that. Trouble was that tc action finds skb->data in different
state so I have to push and pull. Sending v3 shortly.

>
>cheers,
>jamal
>
>---
>export TC=/media/MT1/other-gits/iproute2-jiri/tc/tc
>export ETH=eth0
>#index supplied by kernel
>sudo $TC actions add action vlan pop
>#explicit add with our index
>sudo $TC actions add action vlan pop index 10
>sudo $TC actions add action vlan push id 123
>sudo $TC actions add action vlan push id 456 protocol 802.1Q
>sudo $TC actions add action vlan push id 789 protocol 802.1ad
>
>sudo $TC actions ls action vlan
>------ expect something like ----
>        action order 0:  vlan pop
>         index 1 ref 1 bind 0
>
>        action order 1:  vlan push id 123 protocol 802.1Q
>         index 2 ref 1 bind 0
>
>        action order 2:  vlan push id 456 protocol 802.1Q
>         index 3 ref 1 bind 0
>
>        action order 3:  vlan push id 789 protocol 802.1ad
>         index 4 ref 1 bind 0
>
>        action order 4:  vlan pop
>         index 10 ref 1 bind 0
>-------
>#show stats
>sudo $TC -s actions ls action vlan
>
>-------
>        action order 0:  vlan pop
>         index 1 ref 1 bind 0 installed 78 sec used 78 sec
>        Action statistics:
>        Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
>        backlog 0b 0p requeues 0
>
>        action order 1:  vlan push id 123 protocol 802.1Q
>         index 2 ref 1 bind 0 installed 44 sec used 44 sec
>        Action statistics:
>        Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
>        backlog 0b 0p requeues 0
>
>        action order 2:  vlan push id 456 protocol 802.1Q
>         index 3 ref 1 bind 0 installed 42 sec used 42 sec
>        Action statistics:
>        Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
>        backlog 0b 0p requeues 0
>
>        action order 3:  vlan push id 789 protocol 802.1ad
>         index 4 ref 1 bind 0 installed 39 sec used 39 sec
>        Action statistics:
>        Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
>        backlog 0b 0p requeues 0
>
>        action order 4:  vlan pop
>         index 10 ref 1 bind 0 installed 47 sec used 47 sec
>        Action statistics:
>        Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
>        backlog 0b 0p requeues 0
>-----
>
>sudo $TC actions flush action vlan
>#expect all actions to be gone..
>sudo $TC actions ls action vlan
>
>#lets bind actions to filters...
>sudo ip li add dev dummy0 type dummy
>sudo ifconfig dummy0 up
>#
>sudo tc qdisc del dev $ETH ingress
>sudo tc qdisc add dev $ETH ingress
>#
>sudo $TC filter add dev $ETH parent ffff: pref 11 protocol ip \
>u32 match ip src 10.0.0.1 flowid 1:1 \
>action  vlan  push id 123 \
>action mirred egress redirect dev dummy0
>
>window 1> sudo tcpdump -n -i dummy0 -e -X
>window 2> ping -c 1 10.0.0.1
>
>Expect something like:
>52:54:00:c3:4b:c5 > 02:00:00:22:01:01, ethertype 802.1Q (0x8100), length 102:
>vlan 123, p 0, ethertype IPv4, ...
>#now look at the stats..
>sudo $TC -s filter ls dev $ETH parent ffff: protocol ip
>#
>sudo $TC filter add dev $ETH parent ffff: pref 12 protocol ip \
>u32 match ip src 10.0.0.2 flowid 1:2 \
>action vlan push id 456 protocol 802.1Q \
>action mirred egress redirect dev dummy0
>
>sudo tcpdump -n -i dummy0 -X -e
>ping -c 1 10.0.0.2
>#look at the stats..
>sudo $TC -s filter ls dev $ETH parent ffff: protocol ip
>#
>sudo $TC filter add dev $ETH parent ffff: pref 13 protocol ip \
>u32 match ip src 10.0.0.13 flowid 1:13 \
>action vlan push id 789 protocol 802.1ad \
>action mirred egress redirect dev dummy0
>ping -c 1 10.0.0.2
>
>sudo tcpdump -n -i dummy0 -X -e
>Expect ...
>52:54:00:c3:4b:c5 > 02:00:00:22:01:01, ethertype 802.1Q-QinQ (0x88a8), length
>102: vlan 789, p 0, ethertype IPv4,,,
>#
>sudo $TC -s filter ls dev $ETH parent 1: protocol ip
>#
># Speaking in New Brunswickian:
>#             For shits and giggles lets add two vlans ...
># match all pings this time...
>#
>sudo $TC filter add dev $ETH parent ffff: pref 11 protocol ip u32 \
>match ip protocol 1 0xff flowid 1:1 \
>action  vlan  push id 123 \
>action vlan push id 789 protocol 802.1ad \
>action mirred egress redirect dev dummy0
>
>sudo $TC -s filter ls dev $ETH parent ffff: protocol ip
>------
>filter pref 11 u32
>filter pref 11 u32 fh 800: ht divisor 1
>filter pref 11 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1 (rule
>hit 2 success 0)
>  match 00010000/00ff0000 at 8 (success 0 )
>        action order 1:  vlan push id 123 protocol 802.1Q
>         index 13 ref 1 bind 1 installed 6 sec used 6 sec
>        Action statistics:
>        Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
>        backlog 0b 0p requeues 0
>
>        action order 2:  vlan push id 789 protocol 802.1ad
>         index 14 ref 1 bind 1 installed 6 sec used 6 sec
>        Action statistics:
>        Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
>        backlog 0b 0p requeues 0
>
>        action order 3: mirred (Egress Redirect to device dummy0) stolen
>        index 9 ref 1 bind 1 installed 6 sec used 6 sec
>        Action statistics:
>        Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
>        backlog 0b 0p requeues 0
>----
>
>Send 10 pings to 192.168.100.1
>ping 192.168.100.1 -c 10
>
>sudo $TC -s filter ls dev $ETH parent ffff: protocol ip
>------
>filter pref 11 u32
>filter pref 11 u32 fh 800: ht divisor 1
>filter pref 11 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1 (rule
>hit 24 success 10)
>  match 00010000/00ff0000 at 8 (success 10 )
>        action order 1:  vlan push id 123 protocol 802.1Q
>         index 13 ref 1 bind 1 installed 143 sec used 60 sec
>        Action statistics:
>        Sent 840 bytes 10 pkt (dropped 0, overlimits 0 requeues 0)
>        backlog 0b 0p requeues 0
>
>        action order 2:  vlan push id 789 protocol 802.1ad
>         index 14 ref 1 bind 1 installed 143 sec used 60 sec
>        Action statistics:
>        Sent 840 bytes 10 pkt (dropped 0, overlimits 0 requeues 0)
>        backlog 0b 0p requeues 0
>
>        action order 3: mirred (Egress Redirect to device dummy0) stolen
>        index 9 ref 1 bind 1 installed 143 sec used 60 sec
>        Action statistics:
>        Sent 840 bytes 10 pkt (dropped 0, overlimits 0 requeues 0)
>        backlog 0b 0p requeues 0
>--------
>
>As can be seen, the two vlan tags were supposedly added. I am
>not sure how well it worked. I see 4 more bytes added. tcpdump doesnt do
>a good job telling me if it worked...
>
>17:58:31.636816 00:22:01:01:52:54 > 00:00:00:00:02:00, ethertype 802.1Q-QinQ
>(0x88a8), length 106: vlan 789, p 0, LLC, dsap Unknown (0x44) Group, ssap
>Null (0x00) Command, ctrl 0x5400: Information, send seq 0, rcv seq 42, Flags
>[Command], length 88
>        0x0000:  0000 0000 0200 0022 0101 5254 88a8 0315
>        0x0010:  00c3 4500 0054 c06b 0000 4001 704c 8100
>        0x0020:  007b c0a8 6401 c0a8 649f 0000 24b8 027c
>        0x0030:  000a c7e5 6854 0000 0000 e0b4 0900 0000
>        0x0040:  0000 1011 1213 1415 1617 1819 1a1b 1c1d
>        0x0050:  1e1f 2021 2223 2425 2627 2829 2a2b 2c2d
>        0x0060:  2e2f 3031 3233 3435 3637
>
>Here it is with just 802.1q tag...
>17:53:38.198323 52:54:00:c3:4b:c5 > 02:00:00:22:01:01, ethertype 802.1Q
>(0x8100), length 102: vlan 456, p 0, ethertype IPv4, 192.168.100.1 >
>192.168.100.159: ICMP echo reply, id 620, seq 1, length 64
>        0x0000:  0200 0022 0101 5254 00c3 4bc5 8100 01c8
>        0x0010:  0800 4500 0054 c052 0000 4001 7065 c0a8
>        0x0020:  6401 c0a8 649f 0000 6482 026c 0001 a2e4
>        0x0030:  6854 0000 0000 cc04 0300 0000 0000 1011
>        0x0040:  1213 1415 1617 1819 1a1b 1c1d 1e1f 2021
>        0x0050:  2223 2425 2627 2829 2a2b 2c2d 2e2f 3031
>        0x0060:  3233 3435 3637
>
>------------
>
>

^ permalink raw reply

* Re: [RFC] situation with csum_and_copy_... API
From: Linus Torvalds @ 2014-11-18 20:49 UTC (permalink / raw)
  To: Al Viro; +Cc: Network Development, David Miller, Linux Kernel Mailing List
In-Reply-To: <20141118084745.GT7996@ZenIV.linux.org.uk>

On Tue, Nov 18, 2014 at 12:47 AM, Al Viro <viro@zeniv.linux.org.uk> wrote:
> The minimal implementations would be
>
> __wsum csum_and_copy_from_user(const void __user *src, void *dst, int len,
>                                __wsum sum, int *err_ptr)
> {
>         if (unlikely(copy_from_user(dst, src, len) < 0)) {

No. That "< 0" should be "!= 0". The user copy functions return a
positive value of how many bytes they *failed* to copy.

> Note that we are *not* guaranteed that *err_ptr is touched in case of success
> - not all architectures zero it in that case.  Callers must (and do) zero it
> before the call of csum_and_copy_{from,to}_user().  Furthermore, return value
> in case of error is undefined.

Yeah, easy to misuse.

> IMO the calling conventions are atrocious.

Yeah, not pretty. At the same time, the pain of changing what seems to
work might not be worth it.

And quite frankly, I *detest* your patch 3/5.

"access_ok()" isn't that expensive, and removing them as unnecessary
is fraught with errors. We've had several cases of "oops, we used
__get_user() in a loop, because it generates much better code, but
we'd forgotten to do access_ok(), so now people can read kernel data".

I really think that

 (a) using "__get_user/__put_user/__memcpy_from/to_user" should be
avoided unless there is a clear and present performance issue

 (b) when that performance issue is clear and unmistakable, you should
generally have the "access_ok()" check *locally* to the use of unsafe
ops, so that you can *locally* see that it's safe.

 (c) if there is some upper-level check (ie the normal read/write
paths that make *sure* the addresses are fine), and there is some huge
performance issue that means that the local checks would be a problem,
then we should have a big comment about exactly where the checks are
done.

Your 3/5 violates pretty much all of these, imho.

The rest of the patches I have nothing against. I'm a bit worried that
this is stuff that can easily get stupid thinkos (ie exactly due to
things like the argument order thing), and I wonder how much it buys
us, but at least it seems to generally remove more lines than it adds,
and cleans some stuff up, so I'm not against it.

                    Linus

                 Linus

^ permalink raw reply

* Re: [PATCH] fix #51791 - bug? mac 00:00:00:00:00:00 with natsemi DP83815 after driver load
From: David Miller @ 2014-11-18 20:49 UTC (permalink / raw)
  To: devzero; +Cc: netdev
In-Reply-To: <trinity-9c3b63ff-f474-4d99-84d8-29034921bb3c-1416183467662@3capp-webde-bs06>

From: "Roland Kletzing" <devzero@web.de>
Date: Mon, 17 Nov 2014 01:17:47 +0100

> This one should fix Bugzilla #51791 (details below). 
> 
> Natsemi driver does not read MAC correctly from eeprom, while natsemi-diag from nictools-pci does. Apparently, tt`s a timing issue in the kernel driver.
> 
> According to ftp://ftp.gwdg.de/pub/linux/misc/donald.becker/diag/natsemi-diag.c , eeprom_delay(ee_addr) is defined as follows:
> 
> /* Delay between EEPROM clock transitions.
>    This flushes the write buffer to prevent quick double-writes.
> */
> #define eeprom_delay(ee_addr) 	inl(ee_addr); inl(ee_addr)
> 
> while in the natsemi linux kernel driver, the delay is done this way :
> 
> #define eeprom_delay(ee_addr)   readl(ee_addr)
> 
> , which results in the MAC being all zero`s.
> 
> So i simply added a second readl() to increase delay (instead of turning into inl() as proposed before). This may look a little bit ugly, but it`s fixing the problem for me.
> 
> I´m not sure how many natsemi users being left on this planet (probably few), but i guess this change does not do any harm on platforms where the driver does not behave buggy, so please consider adding it to mainline/stable/longterm.
> 
> Signed-off-by: Roland Kletzing <devzero@web.de>

Please post your patch as a clean new email, without quoting things
after your signoff etc.

Also, please break your lines up to 80 columns max.

Thanks.

^ permalink raw reply

* Re: ipx: fix locking regression in ipx_sendmsg and ipx_recvmsg
From: David Miller @ 2014-11-18 20:49 UTC (permalink / raw)
  To: arnd; +Cc: jbohac, acme, netdev
In-Reply-To: <8698539.evYG7fs8jS@wuerfel>

From: Arnd Bergmann <arnd@arndb.de>
Date: Tue, 18 Nov 2014 14:37:26 +0100

> Does ipxrtr_route_packet() actually sleep while waiting for the network,
> or is it possible that you only need to change the recvmsg path?

I went over that code path and it doesn't appear to sleep at all.

^ permalink raw reply

* Re: [PATCH v4 0/4] Add lightweight memory barriers for coherent memory access
From: Linus Torvalds @ 2014-11-18 20:53 UTC (permalink / raw)
  To: Alexander Duyck
  Cc: linux-arch@vger.kernel.org, Network Development,
	Linux Kernel Mailing List, Mathieu Desnoyers, Peter Zijlstra,
	Benjamin Herrenschmidt, Heiko Carstens, Ingo Molnar,
	Michael Neuling, Russell King - ARM Linux, donald.c.skidmore,
	matthew.vick, Geert Uytterhoeven, Jeff Kirsher, Francois Romieu,
	Paul McKenney, nic_swsd, Will Deacon, Michael Ellerman, Tony Luck,
	Oleg Nesterov, Martin Schwidefsky <
In-Reply-To: <20141118172644.26303.37688.stgit@ahduyck-server>

On Tue, Nov 18, 2014 at 9:28 AM, Alexander Duyck
<alexander.h.duyck@redhat.com> wrote:
> These patches introduce two new primitives for synchronizing cache coherent
> memory writes and reads.  These two new primitives are:
>
>         coherent_rmb()
>         coherent_wmb()

So I'm still not convinced about the name. I don't hate it, but if you
ever want to do "read_acquire", then that whole "coherent_" thing does
make for a big mouthful. I don't see why "dma" isn't simpler and more
to the point, and has the advantage of lining up (in documentation
etc) with "smp".

Why would you ever use "coherent_xyz()" on something that isn't about
dma? If it's cache-coherent memory without DMA, you'd use "smp_xyz()",
so I really do prefer that whole "dma-vs-smp" issue, because it talks
about what is actually the important issue. All sane memory is
coherent, after all (and if it isn't, you have other issues than
memory ordering).

                  Linus

^ permalink raw reply

* Re: [PATCH net-next v2] ipvlan: Initial check-in of the IPVLAN driver.
From: David Miller @ 2014-11-18 20:54 UTC (permalink / raw)
  To: maheshb; +Cc: netdev, edumazet, maze, chavey, thockin, brandon.philips, xemul
In-Reply-To: <1416205634-26611-1-git-send-email-maheshb@google.com>

From: Mahesh Bandewar <maheshb@google.com>
Date: Sun, 16 Nov 2014 22:27:14 -0800

> +/* Define IPVL_DEBUG and set the appropriate dbg_level for debugging. */
> +#ifdef	IPVL_DEBUG
> +/*
> + * 1 : non-datapath debugging
> + * 2 : Custom
> + * 3 : function enters and exists.
> + * 4 : printk in data path (be careful!)
> + */
> +#define IPVL_DBG_LEVEL 1
> +#define ipvlan_dbg(level, msg...)	do { \
> +						if (level <= IPVL_DBG_LEVEL) \
> +						printk(KERN_DEBUG msg); \
> +					} while (0)
> +#else
> +#define ipvlan_dbg(level, msg...) do { ; } while (0)
> +#endif

The day of having code use custom local debug logging facilities is long
gone, please use a standard mechanism for this rather than home cooked
reimplementations.

> +/* ---- Prototype declarations ---- */
> +/* ---- ipvlan_main.c ---- */

Everone knows these are prototype declarations by virtue of them being
functions declarations in a header file.

Anyone who wants to know where these are defined can run grep.

So these comments are superfluous, please remove them across this
entire submission.

> +	const struct in_addr *ip4_addr = iaddr;
> +	return jhash_1word(ip4_addr->s_addr, ipvlan_jhash_secret)
> +	       & IPVLAN_HASH_MASK;

When an expression spans multiple lines, lines end rather than begin
with an operator.

> +		if (is_v6 && addr->atype == IPVL_IPV6 &&
> +			ipv6_addr_equal(&addr->ip6addr, iaddr))

For multi-line if() statements, the second line and subsequent lines
must begine exactly at the first column after the openning parenthesis
of the first line.

If you are purely using TAB characters to indent, you are likely doing
it wrong.
> +		if ((is_v6 && addr->atype == IPVL_IPV6 &&
> +		     ipv6_addr_equal(&addr->ip6addr, iaddr))
> +		   || (!is_v6 && addr->atype == IPVL_IPV4 &&
> +		      addr->ip4addr.s_addr == ((struct in_addr *)iaddr)->s_addr)

Lines end, not begin, with operators.

> --- /dev/null
> +++ b/drivers/net/ipvlan/ipvlan_sysfs.c

Please do not add sysfs configuration knobs, netlink is sufficient.

^ permalink raw reply

* Re: [PATCH 0/8] net: fec: assorted cleanup patches
From: David Miller @ 2014-11-18 20:54 UTC (permalink / raw)
  To: LW; +Cc: netdev, Frank.Li, fugang.duan, rmk+kernel
In-Reply-To: <1416217884-20911-1-git-send-email-LW@KARO-electronics.de>

From: Lothar Waßmann <LW@KARO-electronics.de>
Date: Mon, 17 Nov 2014 10:51:16 +0100

> This patch series is a followup to:
> <1415350967-2238-1-git-send-email-LW@KARO-electronics.de>
> [PATCHv4 1/1] net: fec: fix regression on i.MX28 introduced by rx_copybreak support
> to apply the cleanup patches that were originally sent along with the
> bugfix patch.

Series applied, thanks.

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox