netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* pull-request: can 2019-06-07
@ 2019-06-07 21:15 Marc Kleine-Budde
  2019-06-07 21:15 ` [PATCH 1/9] can: usb: Kconfig: Remove duplicate menu entry Marc Kleine-Budde
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2019-06-07 21:15 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-can, kernel

Hello David,

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

The first patch is by Alexander Dahl and removes a duplicate menu entry from
the Kconfig. The next patch by Joakim Zhang fixes the timeout in the flexcan
driver when setting small bit rates. Anssi Hannula's patch for the xilinx_can
driver fixes the bittiming_const for CAN FD core. The two patches by Sean
Nyekjaer bring mcp25625 to the existing mcp251x driver. The patch by Eugen
Hristev implements an errata for the m_can driver. YueHaibing's patch fixes the
error handling ing can_init(). The patch by Fabio Estevam for the flexcan
driver removes an unneeded registration message during flexcan_probe(). And the
last patch is by Willem de Bruijn and adds the missing purging the  socket
error queue on sock destruct.

regards,
Marc

---

The following changes since commit c7e3c93abbc1382923c7f4fe5ba9ea6aa0fa8d0e:

  Merge tag 'wireless-drivers-for-davem-2019-06-07' of git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers (2019-06-07 12:16:26 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can.git tags/linux-can-fixes-for-5.2-20190607

for you to fetch changes up to fd704bd5ee749d560e86c4f1fd2ef486d8abf7cf:

  can: purge socket error queue on sock destruct (2019-06-07 23:03:54 +0200)

----------------------------------------------------------------
linux-can-fixes-for-5.2-20190607

----------------------------------------------------------------
Alexander Dahl (1):
      can: usb: Kconfig: Remove duplicate menu entry

Anssi Hannula (1):
      can: xilinx_can: use correct bittiming_const for CAN FD core

Eugen Hristev (1):
      can: m_can: implement errata "Needless activation of MRAF irq"

Fabio Estevam (1):
      can: flexcan: Remove unneeded registration message

Joakim Zhang (1):
      can: flexcan: fix timeout when set small bitrate

Sean Nyekjaer (2):
      dt-bindings: can: mcp251x: add mcp25625 support
      can: mcp251x: add support for mcp25625

Willem de Bruijn (1):
      can: purge socket error queue on sock destruct

YueHaibing (1):
      can: af_can: Fix error path of can_init()

 .../bindings/net/can/microchip,mcp251x.txt         |  1 +
 drivers/net/can/flexcan.c                          |  5 +----
 drivers/net/can/m_can/m_can.c                      | 21 ++++++++++++++++++
 drivers/net/can/spi/Kconfig                        |  5 +++--
 drivers/net/can/spi/mcp251x.c                      | 25 ++++++++++++++--------
 drivers/net/can/usb/Kconfig                        |  6 ------
 drivers/net/can/xilinx_can.c                       |  2 +-
 net/can/af_can.c                                   | 25 +++++++++++++++++++---
 8 files changed, 65 insertions(+), 25 deletions(-)




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

* [PATCH 1/9] can: usb: Kconfig: Remove duplicate menu entry
  2019-06-07 21:15 pull-request: can 2019-06-07 Marc Kleine-Budde
@ 2019-06-07 21:15 ` Marc Kleine-Budde
  2019-06-07 21:15 ` [PATCH 2/9] can: flexcan: fix timeout when set small bitrate Marc Kleine-Budde
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2019-06-07 21:15 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-can, kernel, Alexander Dahl, Marc Kleine-Budde

From: Alexander Dahl <ada@thorsis.com>

This seems to have slipped in by accident when sorting the entries.

Fixes: ffbdd9172ee2f53020f763574b4cdad8d9760a4f
Signed-off-by: Alexander Dahl <ada@thorsis.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/Kconfig | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/net/can/usb/Kconfig b/drivers/net/can/usb/Kconfig
index ac3522b77303..4b3d0ddcda79 100644
--- a/drivers/net/can/usb/Kconfig
+++ b/drivers/net/can/usb/Kconfig
@@ -102,12 +102,6 @@ config CAN_PEAK_USB
 
 	  (see also http://www.peak-system.com).
 
-config CAN_MCBA_USB
-	tristate "Microchip CAN BUS Analyzer interface"
-	---help---
-	  This driver supports the CAN BUS Analyzer interface
-	  from Microchip (http://www.microchip.com/development-tools/).
-
 config CAN_UCAN
 	tristate "Theobroma Systems UCAN interface"
 	---help---
-- 
2.20.1


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

* [PATCH 2/9] can: flexcan: fix timeout when set small bitrate
  2019-06-07 21:15 pull-request: can 2019-06-07 Marc Kleine-Budde
  2019-06-07 21:15 ` [PATCH 1/9] can: usb: Kconfig: Remove duplicate menu entry Marc Kleine-Budde
@ 2019-06-07 21:15 ` Marc Kleine-Budde
  2019-06-07 21:15 ` [PATCH 3/9] can: xilinx_can: use correct bittiming_const for CAN FD core Marc Kleine-Budde
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2019-06-07 21:15 UTC (permalink / raw)
  To: netdev
  Cc: davem, linux-can, kernel, Joakim Zhang, Dong Aisheng,
	linux-stable, Marc Kleine-Budde

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

Current we can meet timeout issue when setting a small bitrate like
10000 as follows on i.MX6UL EVK board (ipg clock = 66MHZ, per clock =
30MHZ):

| root@imx6ul7d:~# ip link set can0 up type can bitrate 10000

A link change request failed with some changes committed already.
Interface can0 may have been left with an inconsistent configuration,
please check.

| RTNETLINK answers: Connection timed out

It is caused by calling of flexcan_chip_unfreeze() timeout.

Originally the code is using usleep_range(10, 20) for unfreeze
operation, but the patch (8badd65 can: flexcan: avoid calling
usleep_range from interrupt context) changed it into udelay(10) which is
only a half delay of before, there're also some other delay changes.

After double to FLEXCAN_TIMEOUT_US to 100 can fix the issue.

Meanwhile, Rasmus Villemoes reported that even with a timeout of 100,
flexcan_probe() fails on the MPC8309, which requires a value of at least
140 to work reliably. 250 works for everyone.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/flexcan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 1c66fb2ad76b..f97c628eb2ad 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -166,7 +166,7 @@
 #define FLEXCAN_MB_CNT_LENGTH(x)	(((x) & 0xf) << 16)
 #define FLEXCAN_MB_CNT_TIMESTAMP(x)	((x) & 0xffff)
 
-#define FLEXCAN_TIMEOUT_US		(50)
+#define FLEXCAN_TIMEOUT_US		(250)
 
 /* FLEXCAN hardware feature flags
  *
-- 
2.20.1


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

* [PATCH 3/9] can: xilinx_can: use correct bittiming_const for CAN FD core
  2019-06-07 21:15 pull-request: can 2019-06-07 Marc Kleine-Budde
  2019-06-07 21:15 ` [PATCH 1/9] can: usb: Kconfig: Remove duplicate menu entry Marc Kleine-Budde
  2019-06-07 21:15 ` [PATCH 2/9] can: flexcan: fix timeout when set small bitrate Marc Kleine-Budde
@ 2019-06-07 21:15 ` Marc Kleine-Budde
  2019-06-07 21:15 ` [PATCH 4/9] dt-bindings: can: mcp251x: add mcp25625 support Marc Kleine-Budde
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2019-06-07 21:15 UTC (permalink / raw)
  To: netdev
  Cc: davem, linux-can, kernel, Anssi Hannula, Shubhrajyoti Datta,
	Michal Simek, linux-stable, Marc Kleine-Budde

From: Anssi Hannula <anssi.hannula@bitwise.fi>

Commit 9e5f1b273e6a ("can: xilinx_can: add support for Xilinx CAN FD
core") added a new can_bittiming_const structure for CAN FD cores that
support larger values for tseg1, tseg2, and sjw than previous Xilinx CAN
cores, but the commit did not actually take that into use.

Fix that.

Tested with CAN FD core on a ZynqMP board.

Fixes: 9e5f1b273e6a ("can: xilinx_can: add support for Xilinx CAN FD core")
Reported-by: Shubhrajyoti Datta <shubhrajyoti.datta@gmail.com>
Signed-off-by: Anssi Hannula <anssi.hannula@bitwise.fi>
Cc: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Shubhrajyoti Datta <shubhrajyoti.datta@gmail.com>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/xilinx_can.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c
index f2024404b8d6..63203ff452b5 100644
--- a/drivers/net/can/xilinx_can.c
+++ b/drivers/net/can/xilinx_can.c
@@ -1435,7 +1435,7 @@ static const struct xcan_devtype_data xcan_canfd_data = {
 		 XCAN_FLAG_RXMNF |
 		 XCAN_FLAG_TX_MAILBOXES |
 		 XCAN_FLAG_RX_FIFO_MULTI,
-	.bittiming_const = &xcan_bittiming_const,
+	.bittiming_const = &xcan_bittiming_const_canfd,
 	.btr_ts2_shift = XCAN_BTR_TS2_SHIFT_CANFD,
 	.btr_sjw_shift = XCAN_BTR_SJW_SHIFT_CANFD,
 	.bus_clk_name = "s_axi_aclk",
-- 
2.20.1


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

* [PATCH 4/9] dt-bindings: can: mcp251x: add mcp25625 support
  2019-06-07 21:15 pull-request: can 2019-06-07 Marc Kleine-Budde
                   ` (2 preceding siblings ...)
  2019-06-07 21:15 ` [PATCH 3/9] can: xilinx_can: use correct bittiming_const for CAN FD core Marc Kleine-Budde
@ 2019-06-07 21:15 ` Marc Kleine-Budde
  2019-06-07 21:15 ` [PATCH 5/9] can: mcp251x: add support for mcp25625 Marc Kleine-Budde
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2019-06-07 21:15 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-can, kernel, Sean Nyekjaer, Marc Kleine-Budde

From: Sean Nyekjaer <sean@geanix.com>

Fully compatible with mcp2515, the mcp25625 have integrated transceiver.

This patch add the mcp25625 to the device tree bindings documentation.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 Documentation/devicetree/bindings/net/can/microchip,mcp251x.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/net/can/microchip,mcp251x.txt b/Documentation/devicetree/bindings/net/can/microchip,mcp251x.txt
index 188c8bd4eb67..5a0111d4de58 100644
--- a/Documentation/devicetree/bindings/net/can/microchip,mcp251x.txt
+++ b/Documentation/devicetree/bindings/net/can/microchip,mcp251x.txt
@@ -4,6 +4,7 @@ Required properties:
  - compatible: Should be one of the following:
    - "microchip,mcp2510" for MCP2510.
    - "microchip,mcp2515" for MCP2515.
+   - "microchip,mcp25625" for MCP25625.
  - reg: SPI chip select.
  - clocks: The clock feeding the CAN controller.
  - interrupts: Should contain IRQ line for the CAN controller.
-- 
2.20.1


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

* [PATCH 5/9] can: mcp251x: add support for mcp25625
  2019-06-07 21:15 pull-request: can 2019-06-07 Marc Kleine-Budde
                   ` (3 preceding siblings ...)
  2019-06-07 21:15 ` [PATCH 4/9] dt-bindings: can: mcp251x: add mcp25625 support Marc Kleine-Budde
@ 2019-06-07 21:15 ` Marc Kleine-Budde
  2019-06-07 21:15 ` [PATCH 6/9] can: m_can: implement errata "Needless activation of MRAF irq" Marc Kleine-Budde
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2019-06-07 21:15 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-can, kernel, Sean Nyekjaer, Marc Kleine-Budde

From: Sean Nyekjaer <sean@geanix.com>

Fully compatible with mcp2515, the mcp25625 have integrated transceiver.

This patch adds support for the mcp25625 to the existing mcp251x driver.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/spi/Kconfig   |  5 +++--
 drivers/net/can/spi/mcp251x.c | 25 ++++++++++++++++---------
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/drivers/net/can/spi/Kconfig b/drivers/net/can/spi/Kconfig
index 2e7e535e9237..1c50788055cb 100644
--- a/drivers/net/can/spi/Kconfig
+++ b/drivers/net/can/spi/Kconfig
@@ -9,9 +9,10 @@ config CAN_HI311X
 	  Driver for the Holt HI311x SPI CAN controllers.
 
 config CAN_MCP251X
-	tristate "Microchip MCP251x SPI CAN controllers"
+	tristate "Microchip MCP251x and MCP25625 SPI CAN controllers"
 	depends on HAS_DMA
 	---help---
-	  Driver for the Microchip MCP251x SPI CAN controllers.
+	  Driver for the Microchip MCP251x and MCP25625 SPI CAN
+	  controllers.
 
 endmenu
diff --git a/drivers/net/can/spi/mcp251x.c b/drivers/net/can/spi/mcp251x.c
index e90817608645..da64e71a62ee 100644
--- a/drivers/net/can/spi/mcp251x.c
+++ b/drivers/net/can/spi/mcp251x.c
@@ -1,5 +1,5 @@
 /*
- * CAN bus driver for Microchip 251x CAN Controller with SPI Interface
+ * CAN bus driver for Microchip 251x/25625 CAN Controller with SPI Interface
  *
  * MCP2510 support and bug fixes by Christian Pellegrin
  * <chripell@evolware.org>
@@ -41,7 +41,7 @@
  * static struct spi_board_info spi_board_info[] = {
  *         {
  *                 .modalias = "mcp2510",
- *			// or "mcp2515" depending on your controller
+ *			// "mcp2515" or "mcp25625" depending on your controller
  *                 .platform_data = &mcp251x_info,
  *                 .irq = IRQ_EINT13,
  *                 .max_speed_hz = 2*1000*1000,
@@ -238,6 +238,7 @@ static const struct can_bittiming_const mcp251x_bittiming_const = {
 enum mcp251x_model {
 	CAN_MCP251X_MCP2510	= 0x2510,
 	CAN_MCP251X_MCP2515	= 0x2515,
+	CAN_MCP251X_MCP25625	= 0x25625,
 };
 
 struct mcp251x_priv {
@@ -280,7 +281,6 @@ static inline int mcp251x_is_##_model(struct spi_device *spi) \
 }
 
 MCP251X_IS(2510);
-MCP251X_IS(2515);
 
 static void mcp251x_clean(struct net_device *net)
 {
@@ -639,7 +639,7 @@ static int mcp251x_hw_reset(struct spi_device *spi)
 
 	/* Wait for oscillator startup timer after reset */
 	mdelay(MCP251X_OST_DELAY_MS);
-	
+
 	reg = mcp251x_read_reg(spi, CANSTAT);
 	if ((reg & CANCTRL_REQOP_MASK) != CANCTRL_REQOP_CONF)
 		return -ENODEV;
@@ -820,9 +820,8 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
 		/* receive buffer 0 */
 		if (intf & CANINTF_RX0IF) {
 			mcp251x_hw_rx(spi, 0);
-			/*
-			 * Free one buffer ASAP
-			 * (The MCP2515 does this automatically.)
+			/* Free one buffer ASAP
+			 * (The MCP2515/25625 does this automatically.)
 			 */
 			if (mcp251x_is_2510(spi))
 				mcp251x_write_bits(spi, CANINTF, CANINTF_RX0IF, 0x00);
@@ -831,7 +830,7 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
 		/* receive buffer 1 */
 		if (intf & CANINTF_RX1IF) {
 			mcp251x_hw_rx(spi, 1);
-			/* the MCP2515 does this automatically */
+			/* The MCP2515/25625 does this automatically. */
 			if (mcp251x_is_2510(spi))
 				clear_intf |= CANINTF_RX1IF;
 		}
@@ -1006,6 +1005,10 @@ static const struct of_device_id mcp251x_of_match[] = {
 		.compatible	= "microchip,mcp2515",
 		.data		= (void *)CAN_MCP251X_MCP2515,
 	},
+	{
+		.compatible	= "microchip,mcp25625",
+		.data		= (void *)CAN_MCP251X_MCP25625,
+	},
 	{ }
 };
 MODULE_DEVICE_TABLE(of, mcp251x_of_match);
@@ -1019,6 +1022,10 @@ static const struct spi_device_id mcp251x_id_table[] = {
 		.name		= "mcp2515",
 		.driver_data	= (kernel_ulong_t)CAN_MCP251X_MCP2515,
 	},
+	{
+		.name		= "mcp25625",
+		.driver_data	= (kernel_ulong_t)CAN_MCP251X_MCP25625,
+	},
 	{ }
 };
 MODULE_DEVICE_TABLE(spi, mcp251x_id_table);
@@ -1259,5 +1266,5 @@ module_spi_driver(mcp251x_can_driver);
 
 MODULE_AUTHOR("Chris Elston <celston@katalix.com>, "
 	      "Christian Pellegrin <chripell@evolware.org>");
-MODULE_DESCRIPTION("Microchip 251x CAN driver");
+MODULE_DESCRIPTION("Microchip 251x/25625 CAN driver");
 MODULE_LICENSE("GPL v2");
-- 
2.20.1


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

* [PATCH 6/9] can: m_can: implement errata "Needless activation of MRAF irq"
  2019-06-07 21:15 pull-request: can 2019-06-07 Marc Kleine-Budde
                   ` (4 preceding siblings ...)
  2019-06-07 21:15 ` [PATCH 5/9] can: mcp251x: add support for mcp25625 Marc Kleine-Budde
@ 2019-06-07 21:15 ` Marc Kleine-Budde
  2019-06-07 21:15 ` [PATCH 7/9] can: af_can: Fix error path of can_init() Marc Kleine-Budde
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2019-06-07 21:15 UTC (permalink / raw)
  To: netdev
  Cc: davem, linux-can, kernel, Eugen Hristev, Ludovic Desroches,
	Marc Kleine-Budde

From: Eugen Hristev <eugen.hristev@microchip.com>

During frame reception while the MCAN is in Error Passive state and the
Receive Error Counter has thevalue MCAN_ECR.REC = 127, it may happen
that MCAN_IR.MRAF is set although there was no Message RAM access
failure. If MCAN_IR.MRAF is enabled, an interrupt to the Host CPU is
generated.

Work around:
The Message RAM Access Failure interrupt routine needs to check whether

    MCAN_ECR.RP = '1' and MCAN_ECR.REC = '127'.

In this case, reset MCAN_IR.MRAF. No further action is required.
This affects versions older than 3.2.0

Errata explained on Sama5d2 SoC which includes this hardware block:
http://ww1.microchip.com/downloads/en/DeviceDoc/SAMA5D2-Family-Silicon-Errata-and-Data-Sheet-Clarification-DS80000803B.pdf
chapter 6.2

Reproducibility: If 2 devices with m_can are connected back to back,
configuring different bitrate on them will lead to interrupt storm on
the receiving side, with error "Message RAM access failure occurred".
Another way is to have a bad hardware connection. Bad wire connection
can lead to this issue as well.

This patch fixes the issue according to provided workaround.

Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Reviewed-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/m_can/m_can.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 9b449400376b..deb274a19ba0 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -822,6 +822,27 @@ static int m_can_poll(struct napi_struct *napi, int quota)
 	if (!irqstatus)
 		goto end;
 
+	/* Errata workaround for issue "Needless activation of MRAF irq"
+	 * During frame reception while the MCAN is in Error Passive state
+	 * and the Receive Error Counter has the value MCAN_ECR.REC = 127,
+	 * it may happen that MCAN_IR.MRAF is set although there was no
+	 * Message RAM access failure.
+	 * If MCAN_IR.MRAF is enabled, an interrupt to the Host CPU is generated
+	 * The Message RAM Access Failure interrupt routine needs to check
+	 * whether MCAN_ECR.RP = ’1’ and MCAN_ECR.REC = 127.
+	 * In this case, reset MCAN_IR.MRAF. No further action is required.
+	 */
+	if ((priv->version <= 31) && (irqstatus & IR_MRAF) &&
+	    (m_can_read(priv, M_CAN_ECR) & ECR_RP)) {
+		struct can_berr_counter bec;
+
+		__m_can_get_berr_counter(dev, &bec);
+		if (bec.rxerr == 127) {
+			m_can_write(priv, M_CAN_IR, IR_MRAF);
+			irqstatus &= ~IR_MRAF;
+		}
+	}
+
 	psr = m_can_read(priv, M_CAN_PSR);
 	if (irqstatus & IR_ERR_STATE)
 		work_done += m_can_handle_state_errors(dev, psr);
-- 
2.20.1


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

* [PATCH 7/9] can: af_can: Fix error path of can_init()
  2019-06-07 21:15 pull-request: can 2019-06-07 Marc Kleine-Budde
                   ` (5 preceding siblings ...)
  2019-06-07 21:15 ` [PATCH 6/9] can: m_can: implement errata "Needless activation of MRAF irq" Marc Kleine-Budde
@ 2019-06-07 21:15 ` Marc Kleine-Budde
  2019-06-07 21:15 ` [PATCH 8/9] can: flexcan: Remove unneeded registration message Marc Kleine-Budde
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2019-06-07 21:15 UTC (permalink / raw)
  To: netdev
  Cc: davem, linux-can, kernel, YueHaibing, Oliver Hartkopp, Marc Kleine-Budde

From: YueHaibing <yuehaibing@huawei.com>

This patch add error path for can_init() to avoid possible crash if some
error occurs.

Fixes: 0d66548a10cb ("[CAN]: Add PF_CAN core module")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 net/can/af_can.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/net/can/af_can.c b/net/can/af_can.c
index e8fd5dc1780a..743470680127 100644
--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -952,6 +952,8 @@ static struct pernet_operations can_pernet_ops __read_mostly = {
 
 static __init int can_init(void)
 {
+	int err;
+
 	/* check for correct padding to be able to use the structs similarly */
 	BUILD_BUG_ON(offsetof(struct can_frame, can_dlc) !=
 		     offsetof(struct canfd_frame, len) ||
@@ -965,15 +967,31 @@ static __init int can_init(void)
 	if (!rcv_cache)
 		return -ENOMEM;
 
-	register_pernet_subsys(&can_pernet_ops);
+	err = register_pernet_subsys(&can_pernet_ops);
+	if (err)
+		goto out_pernet;
 
 	/* protocol register */
-	sock_register(&can_family_ops);
-	register_netdevice_notifier(&can_netdev_notifier);
+	err = sock_register(&can_family_ops);
+	if (err)
+		goto out_sock;
+	err = register_netdevice_notifier(&can_netdev_notifier);
+	if (err)
+		goto out_notifier;
+
 	dev_add_pack(&can_packet);
 	dev_add_pack(&canfd_packet);
 
 	return 0;
+
+out_notifier:
+	sock_unregister(PF_CAN);
+out_sock:
+	unregister_pernet_subsys(&can_pernet_ops);
+out_pernet:
+	kmem_cache_destroy(rcv_cache);
+
+	return err;
 }
 
 static __exit void can_exit(void)
-- 
2.20.1


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

* [PATCH 8/9] can: flexcan: Remove unneeded registration message
  2019-06-07 21:15 pull-request: can 2019-06-07 Marc Kleine-Budde
                   ` (6 preceding siblings ...)
  2019-06-07 21:15 ` [PATCH 7/9] can: af_can: Fix error path of can_init() Marc Kleine-Budde
@ 2019-06-07 21:15 ` Marc Kleine-Budde
  2019-06-07 21:15 ` [PATCH 9/9] can: purge socket error queue on sock destruct Marc Kleine-Budde
  2019-06-10  2:44 ` pull-request: can 2019-06-07 David Miller
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2019-06-07 21:15 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-can, kernel, Fabio Estevam, Marc Kleine-Budde

From: Fabio Estevam <festevam@gmail.com>

Currently the following message is observed when the flexcan
driver is probed:

flexcan 2090000.flexcan: device registered (reg_base=(ptrval), irq=23)

The reason for printing 'ptrval' is explained at
Documentation/core-api/printk-formats.rst:

"Pointers printed without a specifier extension (i.e unadorned %p) are
hashed to prevent leaking information about the kernel memory layout. This
has the added benefit of providing a unique identifier. On 64-bit machines
the first 32 bits are zeroed. The kernel will print ``(ptrval)`` until it
gathers enough entropy."

Instead of passing %pK, which can print the correct address, simply
remove the entire message as it is not really that useful.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/flexcan.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index f97c628eb2ad..f2fe344593d5 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -1583,9 +1583,6 @@ static int flexcan_probe(struct platform_device *pdev)
 			dev_dbg(&pdev->dev, "failed to setup stop-mode\n");
 	}
 
-	dev_info(&pdev->dev, "device registered (reg_base=%p, irq=%d)\n",
-		 priv->regs, dev->irq);
-
 	return 0;
 
  failed_register:
-- 
2.20.1


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

* [PATCH 9/9] can: purge socket error queue on sock destruct
  2019-06-07 21:15 pull-request: can 2019-06-07 Marc Kleine-Budde
                   ` (7 preceding siblings ...)
  2019-06-07 21:15 ` [PATCH 8/9] can: flexcan: Remove unneeded registration message Marc Kleine-Budde
@ 2019-06-07 21:15 ` Marc Kleine-Budde
  2019-06-10  2:44 ` pull-request: can 2019-06-07 David Miller
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2019-06-07 21:15 UTC (permalink / raw)
  To: netdev
  Cc: davem, linux-can, kernel, Willem de Bruijn,
	syzbot+a90604060cb40f5bdd16, linux-stable, Marc Kleine-Budde

From: Willem de Bruijn <willemb@google.com>

CAN supports software tx timestamps as of the below commit. Purge
any queued timestamp packets on socket destroy.

Fixes: 51f31cabe3ce ("ip: support for TX timestamps on UDP and RAW sockets")
Reported-by: syzbot+a90604060cb40f5bdd16@syzkaller.appspotmail.com
Signed-off-by: Willem de Bruijn <willemb@google.com>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 net/can/af_can.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/can/af_can.c b/net/can/af_can.c
index 743470680127..80281ef2ccbd 100644
--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -99,6 +99,7 @@ EXPORT_SYMBOL(can_ioctl);
 static void can_sock_destruct(struct sock *sk)
 {
 	skb_queue_purge(&sk->sk_receive_queue);
+	skb_queue_purge(&sk->sk_error_queue);
 }
 
 static const struct can_proto *can_get_proto(int protocol)
-- 
2.20.1


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

* Re: pull-request: can 2019-06-07
  2019-06-07 21:15 pull-request: can 2019-06-07 Marc Kleine-Budde
                   ` (8 preceding siblings ...)
  2019-06-07 21:15 ` [PATCH 9/9] can: purge socket error queue on sock destruct Marc Kleine-Budde
@ 2019-06-10  2:44 ` David Miller
  9 siblings, 0 replies; 11+ messages in thread
From: David Miller @ 2019-06-10  2:44 UTC (permalink / raw)
  To: mkl; +Cc: netdev, linux-can, kernel

From: Marc Kleine-Budde <mkl@pengutronix.de>
Date: Fri,  7 Jun 2019 23:15:32 +0200

> this is a pull reqeust of 9 patches for net/master.
> 
> The first patch is by Alexander Dahl and removes a duplicate menu entry from
> the Kconfig. The next patch by Joakim Zhang fixes the timeout in the flexcan
> driver when setting small bit rates. Anssi Hannula's patch for the xilinx_can
> driver fixes the bittiming_const for CAN FD core. The two patches by Sean
> Nyekjaer bring mcp25625 to the existing mcp251x driver. The patch by Eugen
> Hristev implements an errata for the m_can driver. YueHaibing's patch fixes the
> error handling ing can_init(). The patch by Fabio Estevam for the flexcan
> driver removes an unneeded registration message during flexcan_probe(). And the
> last patch is by Willem de Bruijn and adds the missing purging the  socket
> error queue on sock destruct.

Pulled, thanks Marc.

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

end of thread, other threads:[~2019-06-10  2:44 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-07 21:15 pull-request: can 2019-06-07 Marc Kleine-Budde
2019-06-07 21:15 ` [PATCH 1/9] can: usb: Kconfig: Remove duplicate menu entry Marc Kleine-Budde
2019-06-07 21:15 ` [PATCH 2/9] can: flexcan: fix timeout when set small bitrate Marc Kleine-Budde
2019-06-07 21:15 ` [PATCH 3/9] can: xilinx_can: use correct bittiming_const for CAN FD core Marc Kleine-Budde
2019-06-07 21:15 ` [PATCH 4/9] dt-bindings: can: mcp251x: add mcp25625 support Marc Kleine-Budde
2019-06-07 21:15 ` [PATCH 5/9] can: mcp251x: add support for mcp25625 Marc Kleine-Budde
2019-06-07 21:15 ` [PATCH 6/9] can: m_can: implement errata "Needless activation of MRAF irq" Marc Kleine-Budde
2019-06-07 21:15 ` [PATCH 7/9] can: af_can: Fix error path of can_init() Marc Kleine-Budde
2019-06-07 21:15 ` [PATCH 8/9] can: flexcan: Remove unneeded registration message Marc Kleine-Budde
2019-06-07 21:15 ` [PATCH 9/9] can: purge socket error queue on sock destruct Marc Kleine-Budde
2019-06-10  2:44 ` pull-request: can 2019-06-07 David Miller

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