All of lore.kernel.org
 help / color / mirror / Atom feed
* pull-request: can 2018-03-12
@ 2018-03-12 10:04 Marc Kleine-Budde
  2018-03-12 10:04 ` [PATCH 1/6] can: m_can: change comparison to bitshift when dealing with a mask Marc Kleine-Budde
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Marc Kleine-Budde @ 2018-03-12 10:04 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-can, kernel

Hello David,

this is a pull reqeust of 6 patches for net/master.

The first patch is by Wolfram Sang and fixes a bitshift vs. comparison mistake
in the m_can driver. Two patches of Marek Vasut repair the error handling in
the ifi driver. The two patches by Stephane Grosjean fix a "echo_skb is
occupied!" bug in the peak/pcie_fd driver. Bich HEMON's patch adds pinctrl
select state calls to the m_can's driver to further improve power saving during
suspend.

regards,
Marc

---

The following changes since commit ddc502dfed600bff0b61d899f70d95b76223fdfc:

  openvswitch: meter: fix the incorrect calculation of max delta_t (2018-03-11 22:48:59 -0400)

are available in the Git repository at:

  ssh://git@gitolite.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can.git tags/linux-can-fixes-for-4.16-20180312

for you to fetch changes up to c9b3bce18da4a0aebc27853052dea39aa64b7d75:

  can: m_can: select pinctrl state in each suspend/resume function (2018-03-12 10:38:20 +0100)

----------------------------------------------------------------
linux-can-fixes-for-4.16-20180312

----------------------------------------------------------------
Bich HEMON (1):
      can: m_can: select pinctrl state in each suspend/resume function

Marek Vasut (2):
      can: ifi: Check core revision upon probe
      can: ifi: Repair the error handling

Stephane Grosjean (2):
      can: peak/pcie_fd: fix echo_skb is occupied! bug
      can: peak/pcie_fd: remove useless code when interface starts

Wolfram Sang (1):
      can: m_can: change comparison to bitshift when dealing with a mask

 drivers/net/can/ifi_canfd/ifi_canfd.c         | 75 +++++++++++++++++----------
 drivers/net/can/m_can/m_can.c                 |  7 ++-
 drivers/net/can/peak_canfd/peak_canfd.c       | 25 +++------
 drivers/net/can/peak_canfd/peak_pciefd_main.c |  8 ++-
 4 files changed, 67 insertions(+), 48 deletions(-)

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

* [PATCH 1/6] can: m_can: change comparison to bitshift when dealing with a mask
  2018-03-12 10:04 pull-request: can 2018-03-12 Marc Kleine-Budde
@ 2018-03-12 10:04 ` Marc Kleine-Budde
  2018-03-12 10:04 ` [PATCH 2/6] can: ifi: Check core revision upon probe Marc Kleine-Budde
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Marc Kleine-Budde @ 2018-03-12 10:04 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-can, kernel, Wolfram Sang, Marc Kleine-Budde

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

Due to a typo, the mask was destroyed by a comparison instead of a bit
shift.

Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/m_can/m_can.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 2594f7779c6f..74170b0d23cf 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -253,7 +253,7 @@ enum m_can_mram_cfg {
 
 /* Rx FIFO 0/1 Configuration (RXF0C/RXF1C) */
 #define RXFC_FWM_SHIFT	24
-#define RXFC_FWM_MASK	(0x7f < RXFC_FWM_SHIFT)
+#define RXFC_FWM_MASK	(0x7f << RXFC_FWM_SHIFT)
 #define RXFC_FS_SHIFT	16
 #define RXFC_FS_MASK	(0x7f << RXFC_FS_SHIFT)
 
-- 
2.16.1

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

* [PATCH 2/6] can: ifi: Check core revision upon probe
  2018-03-12 10:04 pull-request: can 2018-03-12 Marc Kleine-Budde
  2018-03-12 10:04 ` [PATCH 1/6] can: m_can: change comparison to bitshift when dealing with a mask Marc Kleine-Budde
@ 2018-03-12 10:04 ` Marc Kleine-Budde
  2018-03-12 10:04 ` [PATCH 3/6] can: ifi: Repair the error handling Marc Kleine-Budde
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Marc Kleine-Budde @ 2018-03-12 10:04 UTC (permalink / raw)
  To: netdev
  Cc: davem, linux-can, kernel, Marek Vasut, Heiko Schocher,
	Markus Marb, Marc Kleine-Budde, linux-stable

From: Marek Vasut <marex@denx.de>

Older versions of the core are not compatible with the driver due
to various intrusive fixes of the core. Read out the VER register,
check the core revision bitfield and verify if the core in use is
new enough (rev 2.1 or newer) to work correctly with this driver.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Heiko Schocher <hs@denx.de>
Cc: Markus Marb <markus@marb.org>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/ifi_canfd/ifi_canfd.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/ifi_canfd/ifi_canfd.c b/drivers/net/can/ifi_canfd/ifi_canfd.c
index 2772d05ff11c..9fd396c3569a 100644
--- a/drivers/net/can/ifi_canfd/ifi_canfd.c
+++ b/drivers/net/can/ifi_canfd/ifi_canfd.c
@@ -136,6 +136,8 @@
 #define IFI_CANFD_SYSCLOCK			0x50
 
 #define IFI_CANFD_VER				0x54
+#define IFI_CANFD_VER_REV_MASK			0xff
+#define IFI_CANFD_VER_REV_MIN_SUPPORTED		0x15
 
 #define IFI_CANFD_IP_ID				0x58
 #define IFI_CANFD_IP_ID_VALUE			0xD073CAFD
@@ -933,7 +935,7 @@ static int ifi_canfd_plat_probe(struct platform_device *pdev)
 	struct resource *res;
 	void __iomem *addr;
 	int irq, ret;
-	u32 id;
+	u32 id, rev;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	addr = devm_ioremap_resource(dev, res);
@@ -947,6 +949,13 @@ static int ifi_canfd_plat_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
+	rev = readl(addr + IFI_CANFD_VER) & IFI_CANFD_VER_REV_MASK;
+	if (rev < IFI_CANFD_VER_REV_MIN_SUPPORTED) {
+		dev_err(dev, "This block is too old (rev %i), minimum supported is rev %i\n",
+			rev, IFI_CANFD_VER_REV_MIN_SUPPORTED);
+		return -EINVAL;
+	}
+
 	ndev = alloc_candev(sizeof(*priv), 1);
 	if (!ndev)
 		return -ENOMEM;
-- 
2.16.1

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

* [PATCH 3/6] can: ifi: Repair the error handling
  2018-03-12 10:04 pull-request: can 2018-03-12 Marc Kleine-Budde
  2018-03-12 10:04 ` [PATCH 1/6] can: m_can: change comparison to bitshift when dealing with a mask Marc Kleine-Budde
  2018-03-12 10:04 ` [PATCH 2/6] can: ifi: Check core revision upon probe Marc Kleine-Budde
@ 2018-03-12 10:04 ` Marc Kleine-Budde
  2018-03-12 10:04 ` [PATCH 4/6] can: peak/pcie_fd: fix echo_skb is occupied! bug Marc Kleine-Budde
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Marc Kleine-Budde @ 2018-03-12 10:04 UTC (permalink / raw)
  To: netdev
  Cc: davem, linux-can, kernel, Marek Vasut, Heiko Schocher,
	Markus Marb, Marc Kleine-Budde, linux-stable

From: Marek Vasut <marex@denx.de>

The new version of the IFI CANFD core has significantly less complex
error state indication logic. In particular, the warning/error state
bits are no longer all over the place, but are all present in the
STATUS register. Moreover, there is a new IRQ register bit indicating
transition between error states (active/warning/passive/busoff).

This patch makes use of this bit to weed out the obscure selective
INTERRUPT register clearing, which was used to carry over the error
state indication into the poll function. While at it, this patch
fixes the handling of the ACTIVE state, since the hardware provides
indication of the core being in ACTIVE state and that in turn fixes
the state transition indication toward userspace. Finally, register
reads in the poll function are moved to the matching subfunctions
since those are also no longer needed in the poll function.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Heiko Schocher <hs@denx.de>
Cc: Markus Marb <markus@marb.org>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/ifi_canfd/ifi_canfd.c | 64 ++++++++++++++++++++---------------
 1 file changed, 37 insertions(+), 27 deletions(-)

diff --git a/drivers/net/can/ifi_canfd/ifi_canfd.c b/drivers/net/can/ifi_canfd/ifi_canfd.c
index 9fd396c3569a..fedd927ba6ed 100644
--- a/drivers/net/can/ifi_canfd/ifi_canfd.c
+++ b/drivers/net/can/ifi_canfd/ifi_canfd.c
@@ -30,6 +30,7 @@
 #define IFI_CANFD_STCMD_ERROR_ACTIVE		BIT(2)
 #define IFI_CANFD_STCMD_ERROR_PASSIVE		BIT(3)
 #define IFI_CANFD_STCMD_BUSOFF			BIT(4)
+#define IFI_CANFD_STCMD_ERROR_WARNING		BIT(5)
 #define IFI_CANFD_STCMD_BUSMONITOR		BIT(16)
 #define IFI_CANFD_STCMD_LOOPBACK		BIT(18)
 #define IFI_CANFD_STCMD_DISABLE_CANFD		BIT(24)
@@ -52,7 +53,10 @@
 #define IFI_CANFD_TXSTCMD_OVERFLOW		BIT(13)
 
 #define IFI_CANFD_INTERRUPT			0xc
+#define IFI_CANFD_INTERRUPT_ERROR_BUSOFF	BIT(0)
 #define IFI_CANFD_INTERRUPT_ERROR_WARNING	BIT(1)
+#define IFI_CANFD_INTERRUPT_ERROR_STATE_CHG	BIT(2)
+#define IFI_CANFD_INTERRUPT_ERROR_REC_TEC_INC	BIT(3)
 #define IFI_CANFD_INTERRUPT_ERROR_COUNTER	BIT(10)
 #define IFI_CANFD_INTERRUPT_TXFIFO_EMPTY	BIT(16)
 #define IFI_CANFD_INTERRUPT_TXFIFO_REMOVE	BIT(22)
@@ -61,6 +65,10 @@
 #define IFI_CANFD_INTERRUPT_SET_IRQ		((u32)BIT(31))
 
 #define IFI_CANFD_IRQMASK			0x10
+#define IFI_CANFD_IRQMASK_ERROR_BUSOFF		BIT(0)
+#define IFI_CANFD_IRQMASK_ERROR_WARNING		BIT(1)
+#define IFI_CANFD_IRQMASK_ERROR_STATE_CHG	BIT(2)
+#define IFI_CANFD_IRQMASK_ERROR_REC_TEC_INC	BIT(3)
 #define IFI_CANFD_IRQMASK_SET_ERR		BIT(7)
 #define IFI_CANFD_IRQMASK_SET_TS		BIT(15)
 #define IFI_CANFD_IRQMASK_TXFIFO_EMPTY		BIT(16)
@@ -222,7 +230,10 @@ static void ifi_canfd_irq_enable(struct net_device *ndev, bool enable)
 
 	if (enable) {
 		enirq = IFI_CANFD_IRQMASK_TXFIFO_EMPTY |
-			IFI_CANFD_IRQMASK_RXFIFO_NEMPTY;
+			IFI_CANFD_IRQMASK_RXFIFO_NEMPTY |
+			IFI_CANFD_IRQMASK_ERROR_STATE_CHG |
+			IFI_CANFD_IRQMASK_ERROR_WARNING |
+			IFI_CANFD_IRQMASK_ERROR_BUSOFF;
 		if (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)
 			enirq |= IFI_CANFD_INTERRUPT_ERROR_COUNTER;
 	}
@@ -363,12 +374,13 @@ static int ifi_canfd_handle_lost_msg(struct net_device *ndev)
 	return 1;
 }
 
-static int ifi_canfd_handle_lec_err(struct net_device *ndev, const u32 errctr)
+static int ifi_canfd_handle_lec_err(struct net_device *ndev)
 {
 	struct ifi_canfd_priv *priv = netdev_priv(ndev);
 	struct net_device_stats *stats = &ndev->stats;
 	struct can_frame *cf;
 	struct sk_buff *skb;
+	u32 errctr = readl(priv->base + IFI_CANFD_ERROR_CTR);
 	const u32 errmask = IFI_CANFD_ERROR_CTR_OVERLOAD_FIRST |
 			    IFI_CANFD_ERROR_CTR_ACK_ERROR_FIRST |
 			    IFI_CANFD_ERROR_CTR_BIT0_ERROR_FIRST |
@@ -451,6 +463,11 @@ static int ifi_canfd_handle_state_change(struct net_device *ndev,
 
 	switch (new_state) {
 	case CAN_STATE_ERROR_ACTIVE:
+		/* error active state */
+		priv->can.can_stats.error_warning++;
+		priv->can.state = CAN_STATE_ERROR_ACTIVE;
+		break;
+	case CAN_STATE_ERROR_WARNING:
 		/* error warning state */
 		priv->can.can_stats.error_warning++;
 		priv->can.state = CAN_STATE_ERROR_WARNING;
@@ -479,7 +496,7 @@ static int ifi_canfd_handle_state_change(struct net_device *ndev,
 	ifi_canfd_get_berr_counter(ndev, &bec);
 
 	switch (new_state) {
-	case CAN_STATE_ERROR_ACTIVE:
+	case CAN_STATE_ERROR_WARNING:
 		/* error warning state */
 		cf->can_id |= CAN_ERR_CRTL;
 		cf->data[1] = (bec.txerr > bec.rxerr) ?
@@ -512,22 +529,21 @@ static int ifi_canfd_handle_state_change(struct net_device *ndev,
 	return 1;
 }
 
-static int ifi_canfd_handle_state_errors(struct net_device *ndev, u32 stcmd)
+static int ifi_canfd_handle_state_errors(struct net_device *ndev)
 {
 	struct ifi_canfd_priv *priv = netdev_priv(ndev);
+	u32 stcmd = readl(priv->base + IFI_CANFD_STCMD);
 	int work_done = 0;
-	u32 isr;
 
-	/*
-	 * The ErrWarn condition is a little special, since the bit is
-	 * located in the INTERRUPT register instead of STCMD register.
-	 */
-	isr = readl(priv->base + IFI_CANFD_INTERRUPT);
-	if ((isr & IFI_CANFD_INTERRUPT_ERROR_WARNING) &&
+	if ((stcmd & IFI_CANFD_STCMD_ERROR_ACTIVE) &&
+	    (priv->can.state != CAN_STATE_ERROR_ACTIVE)) {
+		netdev_dbg(ndev, "Error, entered active state\n");
+		work_done += ifi_canfd_handle_state_change(ndev,
+						CAN_STATE_ERROR_ACTIVE);
+	}
+
+	if ((stcmd & IFI_CANFD_STCMD_ERROR_WARNING) &&
 	    (priv->can.state != CAN_STATE_ERROR_WARNING)) {
-		/* Clear the interrupt */
-		writel(IFI_CANFD_INTERRUPT_ERROR_WARNING,
-		       priv->base + IFI_CANFD_INTERRUPT);
 		netdev_dbg(ndev, "Error, entered warning state\n");
 		work_done += ifi_canfd_handle_state_change(ndev,
 						CAN_STATE_ERROR_WARNING);
@@ -554,18 +570,11 @@ static int ifi_canfd_poll(struct napi_struct *napi, int quota)
 {
 	struct net_device *ndev = napi->dev;
 	struct ifi_canfd_priv *priv = netdev_priv(ndev);
-	const u32 stcmd_state_mask = IFI_CANFD_STCMD_ERROR_PASSIVE |
-				     IFI_CANFD_STCMD_BUSOFF;
-	int work_done = 0;
-
-	u32 stcmd = readl(priv->base + IFI_CANFD_STCMD);
 	u32 rxstcmd = readl(priv->base + IFI_CANFD_RXSTCMD);
-	u32 errctr = readl(priv->base + IFI_CANFD_ERROR_CTR);
+	int work_done = 0;
 
 	/* Handle bus state changes */
-	if ((stcmd & stcmd_state_mask) ||
-	    ((stcmd & IFI_CANFD_STCMD_ERROR_ACTIVE) == 0))
-		work_done += ifi_canfd_handle_state_errors(ndev, stcmd);
+	work_done += ifi_canfd_handle_state_errors(ndev);
 
 	/* Handle lost messages on RX */
 	if (rxstcmd & IFI_CANFD_RXSTCMD_OVERFLOW)
@@ -573,7 +582,7 @@ static int ifi_canfd_poll(struct napi_struct *napi, int quota)
 
 	/* Handle lec errors on the bus */
 	if (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)
-		work_done += ifi_canfd_handle_lec_err(ndev, errctr);
+		work_done += ifi_canfd_handle_lec_err(ndev);
 
 	/* Handle normal messages on RX */
 	if (!(rxstcmd & IFI_CANFD_RXSTCMD_EMPTY))
@@ -594,12 +603,13 @@ static irqreturn_t ifi_canfd_isr(int irq, void *dev_id)
 	struct net_device_stats *stats = &ndev->stats;
 	const u32 rx_irq_mask = IFI_CANFD_INTERRUPT_RXFIFO_NEMPTY |
 				IFI_CANFD_INTERRUPT_RXFIFO_NEMPTY_PER |
+				IFI_CANFD_INTERRUPT_ERROR_COUNTER |
+				IFI_CANFD_INTERRUPT_ERROR_STATE_CHG |
 				IFI_CANFD_INTERRUPT_ERROR_WARNING |
-				IFI_CANFD_INTERRUPT_ERROR_COUNTER;
+				IFI_CANFD_INTERRUPT_ERROR_BUSOFF;
 	const u32 tx_irq_mask = IFI_CANFD_INTERRUPT_TXFIFO_EMPTY |
 				IFI_CANFD_INTERRUPT_TXFIFO_REMOVE;
-	const u32 clr_irq_mask = ~((u32)(IFI_CANFD_INTERRUPT_SET_IRQ |
-					 IFI_CANFD_INTERRUPT_ERROR_WARNING));
+	const u32 clr_irq_mask = ~((u32)IFI_CANFD_INTERRUPT_SET_IRQ);
 	u32 isr;
 
 	isr = readl(priv->base + IFI_CANFD_INTERRUPT);
-- 
2.16.1

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

* [PATCH 4/6] can: peak/pcie_fd: fix echo_skb is occupied! bug
  2018-03-12 10:04 pull-request: can 2018-03-12 Marc Kleine-Budde
                   ` (2 preceding siblings ...)
  2018-03-12 10:04 ` [PATCH 3/6] can: ifi: Repair the error handling Marc Kleine-Budde
@ 2018-03-12 10:04 ` Marc Kleine-Budde
  2018-03-12 10:04 ` [PATCH 5/6] can: peak/pcie_fd: remove useless code when interface starts Marc Kleine-Budde
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Marc Kleine-Budde @ 2018-03-12 10:04 UTC (permalink / raw)
  To: netdev
  Cc: davem, linux-can, kernel, Stephane Grosjean, linux-stable,
	Marc Kleine-Budde

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

This patch makes atomic the handling of the linux-can echo_skb array and
the network tx queue. This prevents from the "BUG! echo_skb is occupied!"
message to be printed by the linux-can core, in SMP environments.

Reported-by: Diana Burgess <diana@peloton-tech.com>
Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/peak_canfd/peak_canfd.c       | 12 ++++++------
 drivers/net/can/peak_canfd/peak_pciefd_main.c |  8 ++++++--
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/net/can/peak_canfd/peak_canfd.c b/drivers/net/can/peak_canfd/peak_canfd.c
index 55513411a82e..6fa66231ed8e 100644
--- a/drivers/net/can/peak_canfd/peak_canfd.c
+++ b/drivers/net/can/peak_canfd/peak_canfd.c
@@ -262,7 +262,6 @@ static int pucan_handle_can_rx(struct peak_canfd_priv *priv,
 
 		spin_lock_irqsave(&priv->echo_lock, flags);
 		can_get_echo_skb(priv->ndev, msg->client);
-		spin_unlock_irqrestore(&priv->echo_lock, flags);
 
 		/* count bytes of the echo instead of skb */
 		stats->tx_bytes += cf_len;
@@ -271,6 +270,7 @@ static int pucan_handle_can_rx(struct peak_canfd_priv *priv,
 		/* restart tx queue (a slot is free) */
 		netif_wake_queue(priv->ndev);
 
+		spin_unlock_irqrestore(&priv->echo_lock, flags);
 		return 0;
 	}
 
@@ -726,11 +726,6 @@ static netdev_tx_t peak_canfd_start_xmit(struct sk_buff *skb,
 	 */
 	should_stop_tx_queue = !!(priv->can.echo_skb[priv->echo_idx]);
 
-	spin_unlock_irqrestore(&priv->echo_lock, flags);
-
-	/* write the skb on the interface */
-	priv->write_tx_msg(priv, msg);
-
 	/* stop network tx queue if not enough room to save one more msg too */
 	if (priv->can.ctrlmode & CAN_CTRLMODE_FD)
 		should_stop_tx_queue |= (room_left <
@@ -742,6 +737,11 @@ static netdev_tx_t peak_canfd_start_xmit(struct sk_buff *skb,
 	if (should_stop_tx_queue)
 		netif_stop_queue(ndev);
 
+	spin_unlock_irqrestore(&priv->echo_lock, flags);
+
+	/* write the skb on the interface */
+	priv->write_tx_msg(priv, msg);
+
 	return NETDEV_TX_OK;
 }
 
diff --git a/drivers/net/can/peak_canfd/peak_pciefd_main.c b/drivers/net/can/peak_canfd/peak_pciefd_main.c
index 788c3464a3b0..3c51a884db87 100644
--- a/drivers/net/can/peak_canfd/peak_pciefd_main.c
+++ b/drivers/net/can/peak_canfd/peak_pciefd_main.c
@@ -349,8 +349,12 @@ static irqreturn_t pciefd_irq_handler(int irq, void *arg)
 		priv->tx_pages_free++;
 		spin_unlock_irqrestore(&priv->tx_lock, flags);
 
-		/* wake producer up */
-		netif_wake_queue(priv->ucan.ndev);
+		/* wake producer up (only if enough room in echo_skb array) */
+		spin_lock_irqsave(&priv->ucan.echo_lock, flags);
+		if (!priv->ucan.can.echo_skb[priv->ucan.echo_idx])
+			netif_wake_queue(priv->ucan.ndev);
+
+		spin_unlock_irqrestore(&priv->ucan.echo_lock, flags);
 	}
 
 	/* re-enable Rx DMA transfer for this CAN */
-- 
2.16.1

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

* [PATCH 5/6] can: peak/pcie_fd: remove useless code when interface starts
  2018-03-12 10:04 pull-request: can 2018-03-12 Marc Kleine-Budde
                   ` (3 preceding siblings ...)
  2018-03-12 10:04 ` [PATCH 4/6] can: peak/pcie_fd: fix echo_skb is occupied! bug Marc Kleine-Budde
@ 2018-03-12 10:04 ` Marc Kleine-Budde
  2018-03-12 10:04 ` [PATCH 6/6] can: m_can: select pinctrl state in each suspend/resume function Marc Kleine-Budde
  2018-03-12 15:17 ` pull-request: can 2018-03-12 David Miller
  6 siblings, 0 replies; 9+ messages in thread
From: Marc Kleine-Budde @ 2018-03-12 10:04 UTC (permalink / raw)
  To: netdev
  Cc: davem, linux-can, kernel, Stephane Grosjean, linux-stable,
	Marc Kleine-Budde

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

When an interface starts, the echo_skb array is empty and the network
queue should be started only. This patch replaces useless code and locks
when the internal RX_BARRIER message is received from the IP core, telling
the driver that tx may start.

Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/peak_canfd/peak_canfd.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/net/can/peak_canfd/peak_canfd.c b/drivers/net/can/peak_canfd/peak_canfd.c
index 6fa66231ed8e..ed8561d4a90f 100644
--- a/drivers/net/can/peak_canfd/peak_canfd.c
+++ b/drivers/net/can/peak_canfd/peak_canfd.c
@@ -333,7 +333,6 @@ static int pucan_handle_status(struct peak_canfd_priv *priv,
 
 	/* this STATUS is the CNF of the RX_BARRIER: Tx path can be setup */
 	if (pucan_status_is_rx_barrier(msg)) {
-		unsigned long flags;
 
 		if (priv->enable_tx_path) {
 			int err = priv->enable_tx_path(priv);
@@ -342,16 +341,8 @@ static int pucan_handle_status(struct peak_canfd_priv *priv,
 				return err;
 		}
 
-		/* restart network queue only if echo skb array is free */
-		spin_lock_irqsave(&priv->echo_lock, flags);
-
-		if (!priv->can.echo_skb[priv->echo_idx]) {
-			spin_unlock_irqrestore(&priv->echo_lock, flags);
-
-			netif_wake_queue(ndev);
-		} else {
-			spin_unlock_irqrestore(&priv->echo_lock, flags);
-		}
+		/* start network queue (echo_skb array is empty) */
+		netif_start_queue(ndev);
 
 		return 0;
 	}
-- 
2.16.1

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

* [PATCH 6/6] can: m_can: select pinctrl state in each suspend/resume function
  2018-03-12 10:04 pull-request: can 2018-03-12 Marc Kleine-Budde
                   ` (4 preceding siblings ...)
  2018-03-12 10:04 ` [PATCH 5/6] can: peak/pcie_fd: remove useless code when interface starts Marc Kleine-Budde
@ 2018-03-12 10:04 ` Marc Kleine-Budde
  2018-03-12 10:30   ` Bich HEMON
  2018-03-12 15:17 ` pull-request: can 2018-03-12 David Miller
  6 siblings, 1 reply; 9+ messages in thread
From: Marc Kleine-Budde @ 2018-03-12 10:04 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-can, kernel, Bich HEMON, Marc Kleine-Budde

From: Bich HEMON <bich.hemon@st.com>

Make sure to apply the correct pin state in suspend/resume callbacks.
Putting pins in sleep state saves power.

Signed-off-by: Bich Hemon <bich.hemon@st.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/m_can/m_can.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 74170b0d23cf..b397a33f3d32 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -26,6 +26,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/iopoll.h>
 #include <linux/can/dev.h>
+#include <linux/pinctrl/consumer.h>
 
 /* napi related */
 #define M_CAN_NAPI_WEIGHT	64
@@ -1700,6 +1701,8 @@ static __maybe_unused int m_can_suspend(struct device *dev)
 		m_can_clk_stop(priv);
 	}
 
+	pinctrl_pm_select_sleep_state(dev);
+
 	priv->can.state = CAN_STATE_SLEEPING;
 
 	return 0;
@@ -1710,6 +1713,8 @@ static __maybe_unused int m_can_resume(struct device *dev)
 	struct net_device *ndev = dev_get_drvdata(dev);
 	struct m_can_priv *priv = netdev_priv(ndev);
 
+	pinctrl_pm_select_default_state(dev);
+
 	m_can_init_ram(priv);
 
 	priv->can.state = CAN_STATE_ERROR_ACTIVE;
-- 
2.16.1

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

* Re: [PATCH 6/6] can: m_can: select pinctrl state in each suspend/resume function
  2018-03-12 10:04 ` [PATCH 6/6] can: m_can: select pinctrl state in each suspend/resume function Marc Kleine-Budde
@ 2018-03-12 10:30   ` Bich HEMON
  0 siblings, 0 replies; 9+ messages in thread
From: Bich HEMON @ 2018-03-12 10:30 UTC (permalink / raw)
  To: Marc Kleine-Budde, netdev; +Cc: davem, linux-can, kernel

Hi Mark,

Thanks for the fix.

On 03/12/2018 11:04 AM, Marc Kleine-Budde wrote:
> From: Bich HEMON <bich.hemon@st.com>
> 
> Make sure to apply the correct pin state in suspend/resume callbacks.
> Putting pins in sleep state saves power.
> 
> Signed-off-by: Bich Hemon <bich.hemon@st.com>
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> ---
>   drivers/net/can/m_can/m_can.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
> index 74170b0d23cf..b397a33f3d32 100644
> --- a/drivers/net/can/m_can/m_can.c
> +++ b/drivers/net/can/m_can/m_can.c
> @@ -26,6 +26,7 @@
>   #include <linux/pm_runtime.h>
>   #include <linux/iopoll.h>
>   #include <linux/can/dev.h>
> +#include <linux/pinctrl/consumer.h>
>   
>   /* napi related */
>   #define M_CAN_NAPI_WEIGHT	64
> @@ -1700,6 +1701,8 @@ static __maybe_unused int m_can_suspend(struct device *dev)
>   		m_can_clk_stop(priv);
>   	}
>   
> +	pinctrl_pm_select_sleep_state(dev);
> +
>   	priv->can.state = CAN_STATE_SLEEPING;
>   
>   	return 0;
> @@ -1710,6 +1713,8 @@ static __maybe_unused int m_can_resume(struct device *dev)
>   	struct net_device *ndev = dev_get_drvdata(dev);
>   	struct m_can_priv *priv = netdev_priv(ndev);
>   
> +	pinctrl_pm_select_default_state(dev);
> +
>   	m_can_init_ram(priv);
>   
>   	priv->can.state = CAN_STATE_ERROR_ACTIVE;
> 

Acked-by: Bich Hemon <bich.hemon@st.com>

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

* Re: pull-request: can 2018-03-12
  2018-03-12 10:04 pull-request: can 2018-03-12 Marc Kleine-Budde
                   ` (5 preceding siblings ...)
  2018-03-12 10:04 ` [PATCH 6/6] can: m_can: select pinctrl state in each suspend/resume function Marc Kleine-Budde
@ 2018-03-12 15:17 ` David Miller
  6 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2018-03-12 15:17 UTC (permalink / raw)
  To: mkl; +Cc: netdev, linux-can, kernel

From: Marc Kleine-Budde <mkl@pengutronix.de>
Date: Mon, 12 Mar 2018 11:04:04 +0100

> this is a pull reqeust of 6 patches for net/master.
> 
> The first patch is by Wolfram Sang and fixes a bitshift vs. comparison mistake
> in the m_can driver. Two patches of Marek Vasut repair the error handling in
> the ifi driver. The two patches by Stephane Grosjean fix a "echo_skb is
> occupied!" bug in the peak/pcie_fd driver. Bich HEMON's patch adds pinctrl
> select state calls to the m_can's driver to further improve power saving during
> suspend.

Pulled, thank you.

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

end of thread, other threads:[~2018-03-12 15:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-12 10:04 pull-request: can 2018-03-12 Marc Kleine-Budde
2018-03-12 10:04 ` [PATCH 1/6] can: m_can: change comparison to bitshift when dealing with a mask Marc Kleine-Budde
2018-03-12 10:04 ` [PATCH 2/6] can: ifi: Check core revision upon probe Marc Kleine-Budde
2018-03-12 10:04 ` [PATCH 3/6] can: ifi: Repair the error handling Marc Kleine-Budde
2018-03-12 10:04 ` [PATCH 4/6] can: peak/pcie_fd: fix echo_skb is occupied! bug Marc Kleine-Budde
2018-03-12 10:04 ` [PATCH 5/6] can: peak/pcie_fd: remove useless code when interface starts Marc Kleine-Budde
2018-03-12 10:04 ` [PATCH 6/6] can: m_can: select pinctrl state in each suspend/resume function Marc Kleine-Budde
2018-03-12 10:30   ` Bich HEMON
2018-03-12 15:17 ` pull-request: can 2018-03-12 David Miller

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.