All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC]: can-next 2021-06-21: try to fix softirq error from threaded IRQs
@ 2021-06-21 12:34 Marc Kleine-Budde
  2021-06-21 12:34 ` [can-next-rfc 1/8] can: rx-offload: add skb queue for use during ISR Marc Kleine-Budde
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2021-06-21 12:34 UTC (permalink / raw)
  To: linux-can; +Cc: kernel, Fabio Estevam

Hello,

this series tries to fix the softirq error which occurs if NAPI is
scheduled from threaded IRQ context [1][2]. Also it fixes a RX-before-TX
problem seen on the mcp251xfd driver.

regards,
Marc

[1] https://lore.kernel.org/r/20210310064626.GA11893@homes.emlix.com
[2] http://lore.kernel.org/r/CAOMZO5AMP537Qz1MAb-D_27C=WH-5Cf602hichxty95A6db9-A@mail.gmail.com





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

* [can-next-rfc 1/8] can: rx-offload: add skb queue for use during ISR
  2021-06-21 12:34 [RFC]: can-next 2021-06-21: try to fix softirq error from threaded IRQs Marc Kleine-Budde
@ 2021-06-21 12:34 ` Marc Kleine-Budde
  2021-06-21 12:34 ` [can-next-rfc 2/8] can: flexcan: convert to can_rx_offload_irq_finish() Marc Kleine-Budde
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2021-06-21 12:34 UTC (permalink / raw)
  To: linux-can; +Cc: kernel, Fabio Estevam, Marc Kleine-Budde, Kurt Van Dijck

Adding a skb to the skb_queue in rx-offload requires to take a lock.

This commit avoids this by adding an unlocked skb queue that is
appended at the end of the ISR. Having one lock at the end of the ISR
should be OK as the HW is empty, not about to overflow.

Co-developed-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/dev/rx-offload.c | 67 ++++++++++++++++----------------
 include/linux/can/rx-offload.h   |  2 +
 2 files changed, 35 insertions(+), 34 deletions(-)

diff --git a/drivers/net/can/dev/rx-offload.c b/drivers/net/can/dev/rx-offload.c
index ab2c1543786c..d0bdb6db3a57 100644
--- a/drivers/net/can/dev/rx-offload.c
+++ b/drivers/net/can/dev/rx-offload.c
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /* Copyright (c) 2014      Protonic Holland,
  *                         David Jander
- * Copyright (C) 2014-2017 Pengutronix,
+ * Copyright (C) 2014-2021 Pengutronix,
  *                         Marc Kleine-Budde <kernel@pengutronix.de>
  */
 
@@ -174,10 +174,8 @@ can_rx_offload_offload_one(struct can_rx_offload *offload, unsigned int n)
 int can_rx_offload_irq_offload_timestamp(struct can_rx_offload *offload,
 					 u64 pending)
 {
-	struct sk_buff_head skb_queue;
 	unsigned int i;
-
-	__skb_queue_head_init(&skb_queue);
+	int received = 0;
 
 	for (i = offload->mb_first;
 	     can_rx_offload_le(offload, i, offload->mb_last);
@@ -191,26 +189,12 @@ int can_rx_offload_irq_offload_timestamp(struct can_rx_offload *offload,
 		if (IS_ERR_OR_NULL(skb))
 			continue;
 
-		__skb_queue_add_sort(&skb_queue, skb, can_rx_offload_compare);
-	}
-
-	if (!skb_queue_empty(&skb_queue)) {
-		unsigned long flags;
-		u32 queue_len;
-
-		spin_lock_irqsave(&offload->skb_queue.lock, flags);
-		skb_queue_splice_tail(&skb_queue, &offload->skb_queue);
-		spin_unlock_irqrestore(&offload->skb_queue.lock, flags);
-
-		queue_len = skb_queue_len(&offload->skb_queue);
-		if (queue_len > offload->skb_queue_len_max / 8)
-			netdev_dbg(offload->dev, "%s: queue_len=%d\n",
-				   __func__, queue_len);
-
-		can_rx_offload_schedule(offload);
+		__skb_queue_add_sort(&offload->skb_irq_queue, skb,
+				     can_rx_offload_compare);
+		received++;
 	}
 
-	return skb_queue_len(&skb_queue);
+	return received;
 }
 EXPORT_SYMBOL_GPL(can_rx_offload_irq_offload_timestamp);
 
@@ -226,13 +210,10 @@ int can_rx_offload_irq_offload_fifo(struct can_rx_offload *offload)
 		if (!skb)
 			break;
 
-		skb_queue_tail(&offload->skb_queue, skb);
+		__skb_queue_tail(&offload->skb_irq_queue, skb);
 		received++;
 	}
 
-	if (received)
-		can_rx_offload_schedule(offload);
-
 	return received;
 }
 EXPORT_SYMBOL_GPL(can_rx_offload_irq_offload_fifo);
@@ -241,7 +222,6 @@ int can_rx_offload_queue_sorted(struct can_rx_offload *offload,
 				struct sk_buff *skb, u32 timestamp)
 {
 	struct can_rx_offload_cb *cb;
-	unsigned long flags;
 
 	if (skb_queue_len(&offload->skb_queue) >
 	    offload->skb_queue_len_max) {
@@ -252,11 +232,8 @@ int can_rx_offload_queue_sorted(struct can_rx_offload *offload,
 	cb = can_rx_offload_get_cb(skb);
 	cb->timestamp = timestamp;
 
-	spin_lock_irqsave(&offload->skb_queue.lock, flags);
-	__skb_queue_add_sort(&offload->skb_queue, skb, can_rx_offload_compare);
-	spin_unlock_irqrestore(&offload->skb_queue.lock, flags);
-
-	can_rx_offload_schedule(offload);
+	__skb_queue_add_sort(&offload->skb_irq_queue, skb,
+			     can_rx_offload_compare);
 
 	return 0;
 }
@@ -295,13 +272,33 @@ int can_rx_offload_queue_tail(struct can_rx_offload *offload,
 		return -ENOBUFS;
 	}
 
-	skb_queue_tail(&offload->skb_queue, skb);
-	can_rx_offload_schedule(offload);
+	__skb_queue_tail(&offload->skb_irq_queue, skb);
 
 	return 0;
 }
 EXPORT_SYMBOL_GPL(can_rx_offload_queue_tail);
 
+void can_rx_offload_irq_finish(struct can_rx_offload *offload)
+{
+	unsigned long flags;
+	int queue_len;
+
+	if (skb_queue_empty_lockless(&offload->skb_irq_queue))
+		return;
+
+	spin_lock_irqsave(&offload->skb_queue.lock, flags);
+	skb_queue_splice_tail_init(&offload->skb_irq_queue, &offload->skb_queue);
+	spin_unlock_irqrestore(&offload->skb_queue.lock, flags);
+
+	queue_len = skb_queue_len(&offload->skb_queue);
+	if (queue_len > offload->skb_queue_len_max / 8)
+		netdev_dbg(offload->dev, "%s: queue_len=%d\n",
+			   __func__, queue_len);
+
+	can_rx_offload_schedule(offload);
+}
+EXPORT_SYMBOL_GPL(can_rx_offload_irq_finish);
+
 static int can_rx_offload_init_queue(struct net_device *dev,
 				     struct can_rx_offload *offload,
 				     unsigned int weight)
@@ -312,6 +309,7 @@ static int can_rx_offload_init_queue(struct net_device *dev,
 	offload->skb_queue_len_max = 2 << fls(weight);
 	offload->skb_queue_len_max *= 4;
 	skb_queue_head_init(&offload->skb_queue);
+	__skb_queue_head_init(&offload->skb_irq_queue);
 
 	netif_napi_add(dev, &offload->napi, can_rx_offload_napi_poll, weight);
 
@@ -373,5 +371,6 @@ void can_rx_offload_del(struct can_rx_offload *offload)
 {
 	netif_napi_del(&offload->napi);
 	skb_queue_purge(&offload->skb_queue);
+	__skb_queue_purge(&offload->skb_irq_queue);
 }
 EXPORT_SYMBOL_GPL(can_rx_offload_del);
diff --git a/include/linux/can/rx-offload.h b/include/linux/can/rx-offload.h
index 40882df7105e..d71c938e17d0 100644
--- a/include/linux/can/rx-offload.h
+++ b/include/linux/can/rx-offload.h
@@ -20,6 +20,7 @@ struct can_rx_offload {
 					bool drop);
 
 	struct sk_buff_head skb_queue;
+	struct sk_buff_head skb_irq_queue;
 	u32 skb_queue_len_max;
 
 	unsigned int mb_first;
@@ -48,6 +49,7 @@ unsigned int can_rx_offload_get_echo_skb(struct can_rx_offload *offload,
 					 unsigned int *frame_len_ptr);
 int can_rx_offload_queue_tail(struct can_rx_offload *offload,
 			      struct sk_buff *skb);
+void can_rx_offload_irq_finish(struct can_rx_offload *offload);
 void can_rx_offload_del(struct can_rx_offload *offload);
 void can_rx_offload_enable(struct can_rx_offload *offload);
 

base-commit: adc2e56ebe6377f5c032d96aee0feac30a640453
-- 
2.30.2



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

* [can-next-rfc 2/8] can: flexcan: convert to can_rx_offload_irq_finish()
  2021-06-21 12:34 [RFC]: can-next 2021-06-21: try to fix softirq error from threaded IRQs Marc Kleine-Budde
  2021-06-21 12:34 ` [can-next-rfc 1/8] can: rx-offload: add skb queue for use during ISR Marc Kleine-Budde
@ 2021-06-21 12:34 ` Marc Kleine-Budde
  2021-06-21 12:34 ` [can-next-rfc 3/8] can: mcp251xfd: " Marc Kleine-Budde
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2021-06-21 12:34 UTC (permalink / raw)
  To: linux-can; +Cc: kernel, Fabio Estevam, Marc Kleine-Budde

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

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 57f3635ad8d7..d9dcf6a8412b 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -1198,6 +1198,9 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)
 		}
 	}
 
+	if (handled)
+		can_rx_offload_irq_finish(&priv->offload);
+
 	return handled;
 }
 
-- 
2.30.2



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

* [can-next-rfc 3/8] can: mcp251xfd: convert to can_rx_offload_irq_finish()
  2021-06-21 12:34 [RFC]: can-next 2021-06-21: try to fix softirq error from threaded IRQs Marc Kleine-Budde
  2021-06-21 12:34 ` [can-next-rfc 1/8] can: rx-offload: add skb queue for use during ISR Marc Kleine-Budde
  2021-06-21 12:34 ` [can-next-rfc 2/8] can: flexcan: convert to can_rx_offload_irq_finish() Marc Kleine-Budde
@ 2021-06-21 12:34 ` Marc Kleine-Budde
  2021-06-21 12:34 ` [can-next-rfc 4/8] can: m_can: " Marc Kleine-Budde
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2021-06-21 12:34 UTC (permalink / raw)
  To: linux-can; +Cc: kernel, Fabio Estevam, Marc Kleine-Budde

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

diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
index 47c3f408a799..f3b267ec22e0 100644
--- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
+++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
@@ -2195,8 +2195,10 @@ static irqreturn_t mcp251xfd_irq(int irq, void *dev_id)
 			FIELD_GET(MCP251XFD_REG_INT_IE_MASK,
 				  priv->regs_status.intf);
 
-		if (!(intf_pending))
+		if (!(intf_pending)) {
+			can_rx_offload_irq_finish(&priv->offload);
 			return handled;
+		}
 
 		/* Some interrupts must be ACKed in the
 		 * MCP251XFD_REG_INT register.
@@ -2296,6 +2298,8 @@ static irqreturn_t mcp251xfd_irq(int irq, void *dev_id)
 	} while (1);
 
  out_fail:
+	can_rx_offload_irq_finish(&priv->offload);
+
 	netdev_err(priv->ndev, "IRQ handler returned %d (intf=0x%08x).\n",
 		   err, priv->regs_status.intf);
 	mcp251xfd_dump(priv);
-- 
2.30.2



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

* [can-next-rfc 4/8] can: m_can: convert to can_rx_offload_irq_finish()
  2021-06-21 12:34 [RFC]: can-next 2021-06-21: try to fix softirq error from threaded IRQs Marc Kleine-Budde
                   ` (2 preceding siblings ...)
  2021-06-21 12:34 ` [can-next-rfc 3/8] can: mcp251xfd: " Marc Kleine-Budde
@ 2021-06-21 12:34 ` Marc Kleine-Budde
  2021-06-21 12:34 ` [can-next-rfc 5/8] can: ti_hecc: " Marc Kleine-Budde
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2021-06-21 12:34 UTC (permalink / raw)
  To: linux-can; +Cc: kernel, Fabio Estevam, Marc Kleine-Budde

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

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index bba2a449ac70..c804419a4153 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -1058,6 +1058,9 @@ static irqreturn_t m_can_isr(int irq, void *dev_id)
 		}
 	}
 
+	if (cdev->is_peripheral)
+		can_rx_offload_irq_finish(&priv->offload);
+
 	return IRQ_HANDLED;
 }
 
-- 
2.30.2



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

* [can-next-rfc 5/8] can: ti_hecc: convert to can_rx_offload_irq_finish()
  2021-06-21 12:34 [RFC]: can-next 2021-06-21: try to fix softirq error from threaded IRQs Marc Kleine-Budde
                   ` (3 preceding siblings ...)
  2021-06-21 12:34 ` [can-next-rfc 4/8] can: m_can: " Marc Kleine-Budde
@ 2021-06-21 12:34 ` Marc Kleine-Budde
  2021-06-21 12:34 ` [can-next-rfc 6/8] can: rx-offload: can_rx_offload_schedule(): remove function Marc Kleine-Budde
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2021-06-21 12:34 UTC (permalink / raw)
  To: linux-can; +Cc: kernel, Fabio Estevam, Marc Kleine-Budde

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

diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
index 73245d8836a9..353062ead98f 100644
--- a/drivers/net/can/ti_hecc.c
+++ b/drivers/net/can/ti_hecc.c
@@ -786,6 +786,8 @@ static irqreturn_t ti_hecc_interrupt(int irq, void *dev_id)
 		int_status = hecc_read(priv, HECC_CANGIF0);
 	}
 
+	can_rx_offload_irq_finish(&priv->offload);
+
 	return IRQ_HANDLED;
 }
 
-- 
2.30.2



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

* [can-next-rfc 6/8] can: rx-offload: can_rx_offload_schedule(): remove function
  2021-06-21 12:34 [RFC]: can-next 2021-06-21: try to fix softirq error from threaded IRQs Marc Kleine-Budde
                   ` (4 preceding siblings ...)
  2021-06-21 12:34 ` [can-next-rfc 5/8] can: ti_hecc: " Marc Kleine-Budde
@ 2021-06-21 12:34 ` Marc Kleine-Budde
  2021-06-21 12:34 ` [can-next-rfc 7/8] can: can_rx_offload_threaded_irq_finish(): add Marc Kleine-Budde
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2021-06-21 12:34 UTC (permalink / raw)
  To: linux-can; +Cc: kernel, Fabio Estevam, Marc Kleine-Budde

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/dev/rx-offload.c | 2 +-
 include/linux/can/rx-offload.h   | 5 -----
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/net/can/dev/rx-offload.c b/drivers/net/can/dev/rx-offload.c
index d0bdb6db3a57..82ade3aa5c13 100644
--- a/drivers/net/can/dev/rx-offload.c
+++ b/drivers/net/can/dev/rx-offload.c
@@ -295,7 +295,7 @@ void can_rx_offload_irq_finish(struct can_rx_offload *offload)
 		netdev_dbg(offload->dev, "%s: queue_len=%d\n",
 			   __func__, queue_len);
 
-	can_rx_offload_schedule(offload);
+	napi_schedule(&offload->napi);
 }
 EXPORT_SYMBOL_GPL(can_rx_offload_irq_finish);
 
diff --git a/include/linux/can/rx-offload.h b/include/linux/can/rx-offload.h
index d71c938e17d0..516f64df0ebc 100644
--- a/include/linux/can/rx-offload.h
+++ b/include/linux/can/rx-offload.h
@@ -53,11 +53,6 @@ void can_rx_offload_irq_finish(struct can_rx_offload *offload);
 void can_rx_offload_del(struct can_rx_offload *offload);
 void can_rx_offload_enable(struct can_rx_offload *offload);
 
-static inline void can_rx_offload_schedule(struct can_rx_offload *offload)
-{
-	napi_schedule(&offload->napi);
-}
-
 static inline void can_rx_offload_disable(struct can_rx_offload *offload)
 {
 	napi_disable(&offload->napi);
-- 
2.30.2



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

* [can-next-rfc 7/8] can: can_rx_offload_threaded_irq_finish(): add
  2021-06-21 12:34 [RFC]: can-next 2021-06-21: try to fix softirq error from threaded IRQs Marc Kleine-Budde
                   ` (5 preceding siblings ...)
  2021-06-21 12:34 ` [can-next-rfc 6/8] can: rx-offload: can_rx_offload_schedule(): remove function Marc Kleine-Budde
@ 2021-06-21 12:34 ` Marc Kleine-Budde
  2021-06-21 12:34 ` [can-next-rfc 8/8] imx6dl-riotboard-can: added Marc Kleine-Budde
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2021-06-21 12:34 UTC (permalink / raw)
  To: linux-can; +Cc: kernel, Fabio Estevam, Marc Kleine-Budde

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/dev/rx-offload.c              | 23 +++++++++++++++++++
 drivers/net/can/m_can/m_can.c                 |  2 +-
 .../net/can/spi/mcp251xfd/mcp251xfd-core.c    |  4 ++--
 include/linux/can/rx-offload.h                |  1 +
 4 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/drivers/net/can/dev/rx-offload.c b/drivers/net/can/dev/rx-offload.c
index 82ade3aa5c13..37b0cc65237b 100644
--- a/drivers/net/can/dev/rx-offload.c
+++ b/drivers/net/can/dev/rx-offload.c
@@ -299,6 +299,29 @@ void can_rx_offload_irq_finish(struct can_rx_offload *offload)
 }
 EXPORT_SYMBOL_GPL(can_rx_offload_irq_finish);
 
+void can_rx_offload_threaded_irq_finish(struct can_rx_offload *offload)
+{
+	unsigned long flags;
+	int queue_len;
+
+	if (skb_queue_empty_lockless(&offload->skb_irq_queue))
+		return;
+
+	spin_lock_irqsave(&offload->skb_queue.lock, flags);
+	skb_queue_splice_tail_init(&offload->skb_irq_queue, &offload->skb_queue);
+	spin_unlock_irqrestore(&offload->skb_queue.lock, flags);
+
+	queue_len = skb_queue_len(&offload->skb_queue);
+	if (queue_len > offload->skb_queue_len_max / 8)
+		netdev_dbg(offload->dev, "%s: queue_len=%d\n",
+			   __func__, queue_len);
+
+	local_bh_disable();
+	napi_schedule(&offload->napi);
+	local_bh_enable();
+}
+EXPORT_SYMBOL_GPL(can_rx_offload_threaded_irq_finish);
+
 static int can_rx_offload_init_queue(struct net_device *dev,
 				     struct can_rx_offload *offload,
 				     unsigned int weight)
diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index c804419a4153..1c12e0ae5d1d 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -1059,7 +1059,7 @@ static irqreturn_t m_can_isr(int irq, void *dev_id)
 	}
 
 	if (cdev->is_peripheral)
-		can_rx_offload_irq_finish(&priv->offload);
+		can_rx_offload_threaded_irq_finish(&priv->offload);
 
 	return IRQ_HANDLED;
 }
diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
index f3b267ec22e0..6962ab2749df 100644
--- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
+++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
@@ -2196,7 +2196,7 @@ static irqreturn_t mcp251xfd_irq(int irq, void *dev_id)
 				  priv->regs_status.intf);
 
 		if (!(intf_pending)) {
-			can_rx_offload_irq_finish(&priv->offload);
+			can_rx_offload_threaded_irq_finish(&priv->offload);
 			return handled;
 		}
 
@@ -2298,7 +2298,7 @@ static irqreturn_t mcp251xfd_irq(int irq, void *dev_id)
 	} while (1);
 
  out_fail:
-	can_rx_offload_irq_finish(&priv->offload);
+	can_rx_offload_threaded_irq_finish(&priv->offload);
 
 	netdev_err(priv->ndev, "IRQ handler returned %d (intf=0x%08x).\n",
 		   err, priv->regs_status.intf);
diff --git a/include/linux/can/rx-offload.h b/include/linux/can/rx-offload.h
index 516f64df0ebc..c11477620403 100644
--- a/include/linux/can/rx-offload.h
+++ b/include/linux/can/rx-offload.h
@@ -50,6 +50,7 @@ unsigned int can_rx_offload_get_echo_skb(struct can_rx_offload *offload,
 int can_rx_offload_queue_tail(struct can_rx_offload *offload,
 			      struct sk_buff *skb);
 void can_rx_offload_irq_finish(struct can_rx_offload *offload);
+void can_rx_offload_threaded_irq_finish(struct can_rx_offload *offload);
 void can_rx_offload_del(struct can_rx_offload *offload);
 void can_rx_offload_enable(struct can_rx_offload *offload);
 
-- 
2.30.2



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

* [can-next-rfc 8/8] imx6dl-riotboard-can: added
  2021-06-21 12:34 [RFC]: can-next 2021-06-21: try to fix softirq error from threaded IRQs Marc Kleine-Budde
                   ` (6 preceding siblings ...)
  2021-06-21 12:34 ` [can-next-rfc 7/8] can: can_rx_offload_threaded_irq_finish(): add Marc Kleine-Budde
@ 2021-06-21 12:34 ` Marc Kleine-Budde
  2021-06-21 12:39 ` [RFC]: can-next 2021-06-21: try to fix softirq error from threaded IRQs Marc Kleine-Budde
  2021-06-24  8:59 ` Oleksij Rempel
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2021-06-21 12:34 UTC (permalink / raw)
  To: linux-can; +Cc: kernel, Fabio Estevam, Marc Kleine-Budde

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 arch/arm/boot/dts/Makefile                 |   1 +
 arch/arm/boot/dts/imx6dl-riotboard-can.dts | 187 +++++++++++++++++++++
 2 files changed, 188 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6dl-riotboard-can.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index f8f09c5066e7..e77c91d4aa27 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -469,6 +469,7 @@ dtb-$(CONFIG_SOC_IMX6Q) += \
 	imx6dl-prtvt7.dtb \
 	imx6dl-rex-basic.dtb \
 	imx6dl-riotboard.dtb \
+	imx6dl-riotboard-can.dtb \
 	imx6dl-sabreauto.dtb \
 	imx6dl-sabrelite.dtb \
 	imx6dl-sabresd.dtb \
diff --git a/arch/arm/boot/dts/imx6dl-riotboard-can.dts b/arch/arm/boot/dts/imx6dl-riotboard-can.dts
new file mode 100644
index 000000000000..5b995496f554
--- /dev/null
+++ b/arch/arm/boot/dts/imx6dl-riotboard-can.dts
@@ -0,0 +1,187 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/dts-v1/;
+
+#include "imx6dl-riotboard.dts"
+
+/ {
+	clocks {
+		mcp251xfd1_osc: mcp251xfd1-osc {
+			compatible = "fixed-clock";
+			#clock-cells = <0>;
+			clock-frequency = <40000000>;
+		};
+
+		mcp251xfd2_osc: mcp251xfd2-osc {
+			compatible = "fixed-clock";
+			#clock-cells = <0>;
+			clock-frequency = <40000000>;
+		};
+
+		tcan4x5x_osc: tcan4x5x-osc {
+			compatible = "fixed-clock";
+			#clock-cells = <0>;
+			clock-frequency = <40000000>;
+		};
+	};
+
+	reg_mcp251xfd1_xceiver: regulator-mcp251xfd1-xceiver {
+		compatible = "regulator-fixed";
+		regulator-name = "mcp251xfd1-xceiver";
+		gpio = <&gpio4 30 GPIO_ACTIVE_LOW>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_mcp251xfd1_xceiver>;
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+	};
+
+	reg_mcp251xfd1_vdd: regulator-mcp251xfd-vdd {
+		compatible = "regulator-fixed";
+		regulator-name = "mcp251xfd1-vdd";
+		gpio = <&gpio4 19 GPIO_ACTIVE_HIGH>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_mcp251xfd1_vdd>;
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		enable-active-high;
+	};
+
+#if 0
+	reg_tcan4x5x_vsup: regulator-tcan4x5x-vsup {
+		compatible = "regulator-fixed";
+		regulator-name = "tcan4x5x-vsup";
+		gpio = <&gpio5 6 GPIO_ACTIVE_LOW>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_tcan4x5x_vsup>;
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		startup-delay-us = <600>;
+	};
+#endif
+};
+
+&iomuxc {
+	pinctrl-names = "default";
+
+	imx6-riotboard {
+		pinctrl_flexcan1: flexcan1_grp {
+			fsl,pins = <
+				MX6QDL_PAD_GPIO_7__FLEXCAN1_TX		0x1b0b0
+				MX6QDL_PAD_GPIO_8__FLEXCAN1_RX		0x1b0b0
+			>;
+		};
+
+		pinctrl_mcp251xfd1_mikrobus: mcp251xfd1_mikrobus_grp {
+			fsl,pins = <
+				MX6QDL_PAD_DISP0_DAT12__GPIO5_IO06	0x1b0b0		// GPIO5_06	-> IRQ
+			>;
+		};
+
+		pinctrl_mcp251xfd1_shield: mcp251xfd1_shield_grp {
+			fsl,pins = <
+				MX6QDL_PAD_DISP0_DAT13__GPIO5_IO07	0x1b0b0		// GPIO5_07	-> IRQ
+			>;
+		};
+
+		pinctrl_mcp251xfd1_xceiver: mcp251xfd1_xceiver_grp {
+			fsl,pins = <
+				MX6QDL_PAD_DISP0_DAT9__GPIO4_IO30	0x1b0b0		// PWM2		-> xceiver
+			>;
+		};
+
+		pinctrl_mcp251xfd1_vdd: mcp251xfd1_vdd_grp {
+			fsl,pins = <
+				MX6QDL_PAD_DI0_PIN3__GPIO4_IO19		0x1b0b0		// GPIO4_19	-> VDD
+			>;
+		};
+
+		pinctrl_mcp251xfd2_shield: mcp251xfd2_shield_grp {
+			fsl,pins = <
+				MX6QDL_PAD_EIM_D25__GPIO3_IO25		0x1b0b0		// UART3_RXD	-> IRQ
+			>;
+
+		};
+#if 0
+		pinctrl_tcan4x5x: tcan4x5xgrp {
+			fsl,pins = <
+				MX6QDL_PAD_DISP0_DAT10__GPIO4_IO31	0x1b0b0		// IRQ
+				MX6QDL_PAD_DISP0_DAT11__GPIO5_IO05	0x1b0b0		// wake
+			>;
+		};
+
+		pinctrl_tcan4x5x_vsup: tcan4x5x_vsup_grp {
+			fsl,pins = <
+				MX6QDL_PAD_DISP0_DAT12__GPIO5_IO06	0x1b0b0
+			>;
+		};
+#endif
+	};
+};
+
+&can1 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_flexcan1>;
+	status = "okay";
+};
+
+&i2c4 {
+	status = "disabled";
+};
+
+&pwm2 {
+	status = "disabled";
+};
+
+&uart3 {
+	status = "disabled";
+};
+
+&ecspi2 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_ecspi2>;
+	cs-gpios = <&gpio5 12 GPIO_ACTIVE_LOW>, <&gpio5 9 GPIO_ACTIVE_LOW>;
+	status = "okay";
+
+	mcp251xfd1: mcp251xfd@0 {
+		reg = <0>;
+		compatible = "microchip,mcp251xfd";
+		xceiver-supply = <&reg_mcp251xfd1_xceiver>;
+		vdd-supply = <&reg_mcp251xfd1_vdd>;
+		pinctrl-names = "default";
+#if 1
+		pinctrl-0 = <&pinctrl_mcp251xfd1_mikrobus>;
+		interrupts-extended = <&gpio5 6 IRQ_TYPE_LEVEL_LOW>;	// mikrobus
+#else
+		pinctrl-0 = <&pinctrl_mcp251xfd1_shield>;
+		interrupts-extended = <&gpio5 7 IRQ_TYPE_LEVEL_LOW>;	// shield
+#endif
+		clocks = <&mcp251xfd1_osc>;
+		spi-max-frequency = <20000000>;
+	};
+
+	mcp251xfd2: mcp251xfd@1 {
+		reg = <1>;
+		compatible = "microchip,mcp251xfd";
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_mcp251xfd2_shield>;
+		interrupts-extended = <&gpio3 25 IRQ_TYPE_LEVEL_LOW>;
+		clocks = <&mcp251xfd2_osc>;
+		spi-max-frequency = <20000000>;
+	};
+
+#if 0
+	tcan4x5x: tcan4x5x@1 {
+		reg = <1>;
+		compatible = "ti,tcan4x5x";
+		vsup-supply = <&reg_tcan4x5x_vsup>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_tcan4x5x>;
+		spi-max-frequency = <10000000>;
+		bosch,mram-cfg = <0x0 0 0 16 0 0 1 1>;
+		interrupt-parent = <&gpio4>;
+		interrupts = <31 IRQ_TYPE_LEVEL_LOW>;
+		clock-names = "cclk";
+		clocks = <&tcan4x5x_osc>;
+		device-wake-gpios = <&gpio5 5 GPIO_ACTIVE_HIGH>;
+	};
+#endif
+};
-- 
2.30.2



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

* Re: [RFC]: can-next 2021-06-21: try to fix softirq error from threaded IRQs
  2021-06-21 12:34 [RFC]: can-next 2021-06-21: try to fix softirq error from threaded IRQs Marc Kleine-Budde
                   ` (7 preceding siblings ...)
  2021-06-21 12:34 ` [can-next-rfc 8/8] imx6dl-riotboard-can: added Marc Kleine-Budde
@ 2021-06-21 12:39 ` Marc Kleine-Budde
  2021-06-24  8:59 ` Oleksij Rempel
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2021-06-21 12:39 UTC (permalink / raw)
  To: linux-can; +Cc: kernel, Fabio Estevam

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

On 21.06.2021 14:34:28, Marc Kleine-Budde wrote:
> Hello,
> 
> this series tries to fix the softirq error which occurs if NAPI is
> scheduled from threaded IRQ context [1][2]. Also it fixes a RX-before-TX
> problem seen on the mcp251xfd driver.

please ignore patch 8/8, as this is obviously the DT of my testing board
:)

Marc

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

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

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

* Re: [RFC]: can-next 2021-06-21: try to fix softirq error from threaded IRQs
  2021-06-21 12:34 [RFC]: can-next 2021-06-21: try to fix softirq error from threaded IRQs Marc Kleine-Budde
                   ` (8 preceding siblings ...)
  2021-06-21 12:39 ` [RFC]: can-next 2021-06-21: try to fix softirq error from threaded IRQs Marc Kleine-Budde
@ 2021-06-24  8:59 ` Oleksij Rempel
  9 siblings, 0 replies; 11+ messages in thread
From: Oleksij Rempel @ 2021-06-24  8:59 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: linux-can, kernel, Fabio Estevam

On Mon, Jun 21, 2021 at 02:34:28PM +0200, Marc Kleine-Budde wrote:
> Hello,
> 
> this series tries to fix the softirq error which occurs if NAPI is
> scheduled from threaded IRQ context [1][2]. Also it fixes a RX-before-TX
> problem seen on the mcp251xfd driver.
> 
> regards,
> Marc
> 
> [1] https://lore.kernel.org/r/20210310064626.GA11893@homes.emlix.com
> [2] http://lore.kernel.org/r/CAOMZO5AMP537Qz1MAb-D_27C=WH-5Cf602hichxty95A6db9-A@mail.gmail.com

Tested on imx6qp with flexcan and mcp251xfd. J1939 works fine, no
RX-before-TX issue was detected (can speed 250K). No lockdep warnings.

Tested-by: Oleksij Rempel <o.rempel@pengutronix.de>

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

end of thread, other threads:[~2021-06-24  8:59 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-21 12:34 [RFC]: can-next 2021-06-21: try to fix softirq error from threaded IRQs Marc Kleine-Budde
2021-06-21 12:34 ` [can-next-rfc 1/8] can: rx-offload: add skb queue for use during ISR Marc Kleine-Budde
2021-06-21 12:34 ` [can-next-rfc 2/8] can: flexcan: convert to can_rx_offload_irq_finish() Marc Kleine-Budde
2021-06-21 12:34 ` [can-next-rfc 3/8] can: mcp251xfd: " Marc Kleine-Budde
2021-06-21 12:34 ` [can-next-rfc 4/8] can: m_can: " Marc Kleine-Budde
2021-06-21 12:34 ` [can-next-rfc 5/8] can: ti_hecc: " Marc Kleine-Budde
2021-06-21 12:34 ` [can-next-rfc 6/8] can: rx-offload: can_rx_offload_schedule(): remove function Marc Kleine-Budde
2021-06-21 12:34 ` [can-next-rfc 7/8] can: can_rx_offload_threaded_irq_finish(): add Marc Kleine-Budde
2021-06-21 12:34 ` [can-next-rfc 8/8] imx6dl-riotboard-can: added Marc Kleine-Budde
2021-06-21 12:39 ` [RFC]: can-next 2021-06-21: try to fix softirq error from threaded IRQs Marc Kleine-Budde
2021-06-24  8:59 ` Oleksij Rempel

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.