netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/9] pull-request: can 2023-05-15
@ 2023-05-15 20:47 Marc Kleine-Budde
  2023-05-15 20:47 ` [PATCH net 1/9] can: isotp: recvmsg(): allow MSG_CMSG_COMPAT flag Marc Kleine-Budde
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2023-05-15 20:47 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel

Hello netdev-team,

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

The first 2 patches are by Oliver Hartkopp and allow the
MSG_CMSG_COMPAT flag for isotp and j1939.

The next patch is by Oliver Hartkopp, too and adds missing CAN XL
support in can_put_echo_skb().

Geert Uytterhoeven's patch let's the bxcan driver depend on
ARCH_STM32.

The last 5 patches are from Dario Binacchi and also affect the bxcan
driver. The bxcan driver hit mainline with v6.4-rc1 and was originally
written for IP cores containing 2 CAN interfaces with shared
resources. Dario's series updates the DT bindings and driver to
support IP cores with a single CAN interface instance as well as
adding the bxcan to the stm32f746's device tree.

regards,
Marc

---

The following changes since commit df0acdc59b094cdaef19b1c8d83c9721082bab7b:

  net: phylink: fix ksettings_set() ethtool call (2023-05-15 10:31:23 +0100)

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-6.4-20230515

for you to fetch changes up to c08e24013aba49a593424715ffc04c928c84b9c9:

  Merge patch series "can: bxcan: add support for single peripheral configuration" (2023-05-15 22:26:39 +0200)

----------------------------------------------------------------
linux-can-fixes-for-6.4-20230515

----------------------------------------------------------------
Dario Binacchi (5):
      dt-bindings: net: can: add "st,can-secondary" property
      ARM: dts: stm32f429: put can2 in secondary mode
      ARM: dts: stm32: add pin map for CAN controller on stm32f7
      can: bxcan: add support for single peripheral configuration
      ARM: dts: stm32: add CAN support on stm32f746

Geert Uytterhoeven (1):
      can: CAN_BXCAN should depend on ARCH_STM32

Marc Kleine-Budde (1):
      Merge patch series "can: bxcan: add support for single peripheral configuration"

Oliver Hartkopp (3):
      can: isotp: recvmsg(): allow MSG_CMSG_COMPAT flag
      can: j1939: recvmsg(): allow MSG_CMSG_COMPAT flag
      can: dev: fix missing CAN XL support in can_put_echo_skb()

 .../bindings/net/can/st,stm32-bxcan.yaml           | 19 +++--
 arch/arm/boot/dts/stm32f429.dtsi                   |  1 +
 arch/arm/boot/dts/stm32f7-pinctrl.dtsi             | 82 ++++++++++++++++++++++
 arch/arm/boot/dts/stm32f746.dtsi                   | 47 +++++++++++++
 drivers/net/can/Kconfig                            |  2 +-
 drivers/net/can/bxcan.c                            | 34 ++++++---
 drivers/net/can/dev/skb.c                          |  3 +-
 net/can/isotp.c                                    |  2 +-
 net/can/j1939/socket.c                             |  2 +-
 9 files changed, 173 insertions(+), 19 deletions(-)



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

* [PATCH net 1/9] can: isotp: recvmsg(): allow MSG_CMSG_COMPAT flag
  2023-05-15 20:47 [PATCH net 0/9] pull-request: can 2023-05-15 Marc Kleine-Budde
@ 2023-05-15 20:47 ` Marc Kleine-Budde
  2023-05-17  4:00   ` patchwork-bot+netdevbpf
  2023-05-15 20:47 ` [PATCH net 2/9] can: j1939: " Marc Kleine-Budde
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 11+ messages in thread
From: Marc Kleine-Budde @ 2023-05-15 20:47 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Oliver Hartkopp, Oleksij Rempel,
	Marc Kleine-Budde, stable

From: Oliver Hartkopp <socketcan@hartkopp.net>

The control message provided by isotp support MSG_CMSG_COMPAT but
blocked recvmsg() syscalls that have set this flag, i.e. on 32bit user
space on 64 bit kernels.

Link: https://github.com/hartkopp/can-isotp/issues/59
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Fixes: 42bf50a1795a ("can: isotp: support MSG_TRUNC flag when reading from socket")
Link: https://lore.kernel.org/20230505110308.81087-2-mkl@pengutronix.de
Cc: stable@vger.kernel.org
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 net/can/isotp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/can/isotp.c b/net/can/isotp.c
index a750259cb79c..84f9aba02901 100644
--- a/net/can/isotp.c
+++ b/net/can/isotp.c
@@ -1139,7 +1139,7 @@ static int isotp_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
 	struct isotp_sock *so = isotp_sk(sk);
 	int ret = 0;
 
-	if (flags & ~(MSG_DONTWAIT | MSG_TRUNC | MSG_PEEK))
+	if (flags & ~(MSG_DONTWAIT | MSG_TRUNC | MSG_PEEK | MSG_CMSG_COMPAT))
 		return -EINVAL;
 
 	if (!so->bound)

base-commit: df0acdc59b094cdaef19b1c8d83c9721082bab7b
-- 
2.39.2



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

* [PATCH net 2/9] can: j1939: recvmsg(): allow MSG_CMSG_COMPAT flag
  2023-05-15 20:47 [PATCH net 0/9] pull-request: can 2023-05-15 Marc Kleine-Budde
  2023-05-15 20:47 ` [PATCH net 1/9] can: isotp: recvmsg(): allow MSG_CMSG_COMPAT flag Marc Kleine-Budde
@ 2023-05-15 20:47 ` Marc Kleine-Budde
  2023-05-15 20:47 ` [PATCH net 3/9] can: dev: fix missing CAN XL support in can_put_echo_skb() Marc Kleine-Budde
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2023-05-15 20:47 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Oliver Hartkopp, Oleksij Rempel,
	Marc Kleine-Budde, stable

From: Oliver Hartkopp <socketcan@hartkopp.net>

The control message provided by J1939 support MSG_CMSG_COMPAT but
blocked recvmsg() syscalls that have set this flag, i.e. on 32bit user
space on 64 bit kernels.

Link: https://github.com/hartkopp/can-isotp/issues/59
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Tested-by: Oleksij Rempel <o.rempel@pengutronix.de>
Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
Link: https://lore.kernel.org/20230505110308.81087-3-mkl@pengutronix.de
Cc: stable@vger.kernel.org
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 net/can/j1939/socket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c
index 7e90f9e61d9b..1790469b2580 100644
--- a/net/can/j1939/socket.c
+++ b/net/can/j1939/socket.c
@@ -798,7 +798,7 @@ static int j1939_sk_recvmsg(struct socket *sock, struct msghdr *msg,
 	struct j1939_sk_buff_cb *skcb;
 	int ret = 0;
 
-	if (flags & ~(MSG_DONTWAIT | MSG_ERRQUEUE))
+	if (flags & ~(MSG_DONTWAIT | MSG_ERRQUEUE | MSG_CMSG_COMPAT))
 		return -EINVAL;
 
 	if (flags & MSG_ERRQUEUE)
-- 
2.39.2



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

* [PATCH net 3/9] can: dev: fix missing CAN XL support in can_put_echo_skb()
  2023-05-15 20:47 [PATCH net 0/9] pull-request: can 2023-05-15 Marc Kleine-Budde
  2023-05-15 20:47 ` [PATCH net 1/9] can: isotp: recvmsg(): allow MSG_CMSG_COMPAT flag Marc Kleine-Budde
  2023-05-15 20:47 ` [PATCH net 2/9] can: j1939: " Marc Kleine-Budde
@ 2023-05-15 20:47 ` Marc Kleine-Budde
  2023-05-15 20:47 ` [PATCH net 4/9] can: CAN_BXCAN should depend on ARCH_STM32 Marc Kleine-Budde
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2023-05-15 20:47 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Oliver Hartkopp,
	Marc Kleine-Budde

From: Oliver Hartkopp <socketcan@hartkopp.net>

can_put_echo_skb() checks for the enabled IFF_ECHO flag and the
correct ETH_P type of the given skbuff. When implementing the CAN XL
support the new check for ETH_P_CANXL has been forgotten.

Fixes: fb08cba12b52 ("can: canxl: update CAN infrastructure for CAN XL frames")
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Link: https://lore.kernel.org/all/20230506184515.39241-1-socketcan@hartkopp.net
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/dev/skb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/dev/skb.c b/drivers/net/can/dev/skb.c
index 241ec636e91f..f6d05b3ef59a 100644
--- a/drivers/net/can/dev/skb.c
+++ b/drivers/net/can/dev/skb.c
@@ -54,7 +54,8 @@ int can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
 	/* check flag whether this packet has to be looped back */
 	if (!(dev->flags & IFF_ECHO) ||
 	    (skb->protocol != htons(ETH_P_CAN) &&
-	     skb->protocol != htons(ETH_P_CANFD))) {
+	     skb->protocol != htons(ETH_P_CANFD) &&
+	     skb->protocol != htons(ETH_P_CANXL))) {
 		kfree_skb(skb);
 		return 0;
 	}
-- 
2.39.2



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

* [PATCH net 4/9] can: CAN_BXCAN should depend on ARCH_STM32
  2023-05-15 20:47 [PATCH net 0/9] pull-request: can 2023-05-15 Marc Kleine-Budde
                   ` (2 preceding siblings ...)
  2023-05-15 20:47 ` [PATCH net 3/9] can: dev: fix missing CAN XL support in can_put_echo_skb() Marc Kleine-Budde
@ 2023-05-15 20:47 ` Marc Kleine-Budde
  2023-05-15 20:47 ` [PATCH net 5/9] dt-bindings: net: can: add "st,can-secondary" property Marc Kleine-Budde
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2023-05-15 20:47 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Geert Uytterhoeven, Simon Horman,
	Marc Kleine-Budde

From: Geert Uytterhoeven <geert+renesas@glider.be>

The STMicroelectronics STM32 basic extended CAN Controller (bxCAN) is
only present on STM32 SoCs.  Hence drop the "|| OF" part from its
dependency rule, to prevent asking the user about this driver when
configuring a kernel without STM32 SoC support.

Fixes: f00647d8127be4d3 ("can: bxcan: add support for ST bxCAN controller")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/all/40095112efd1b2214e4223109fd9f0c6d0158a2d.1680609318.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig
index 3ceccafd701b..b190007c01be 100644
--- a/drivers/net/can/Kconfig
+++ b/drivers/net/can/Kconfig
@@ -95,7 +95,7 @@ config CAN_AT91
 
 config CAN_BXCAN
 	tristate "STM32 Basic Extended CAN (bxCAN) devices"
-	depends on OF || ARCH_STM32 || COMPILE_TEST
+	depends on ARCH_STM32 || COMPILE_TEST
 	depends on HAS_IOMEM
 	select CAN_RX_OFFLOAD
 	help
-- 
2.39.2



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

* [PATCH net 5/9] dt-bindings: net: can: add "st,can-secondary" property
  2023-05-15 20:47 [PATCH net 0/9] pull-request: can 2023-05-15 Marc Kleine-Budde
                   ` (3 preceding siblings ...)
  2023-05-15 20:47 ` [PATCH net 4/9] can: CAN_BXCAN should depend on ARCH_STM32 Marc Kleine-Budde
@ 2023-05-15 20:47 ` Marc Kleine-Budde
  2023-05-15 20:47 ` [PATCH net 6/9] ARM: dts: stm32f429: put can2 in secondary mode Marc Kleine-Budde
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2023-05-15 20:47 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Dario Binacchi, Rob Herring,
	Marc Kleine-Budde

From: Dario Binacchi <dario.binacchi@amarulasolutions.com>

On the stm32f7 Socs the can peripheral can be in single or dual
configuration. In the dual configuration, in turn, it can be in primary
or secondary mode. The addition of the 'st,can-secondary' property allows
you to specify this mode in the dual configuration.

CAN peripheral nodes in single configuration contain neither
"st,can-primary" nor "st,can-secondary".

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/all/20230427204540.3126234-2-dario.binacchi@amarulasolutions.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 .../bindings/net/can/st,stm32-bxcan.yaml      | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/can/st,stm32-bxcan.yaml b/Documentation/devicetree/bindings/net/can/st,stm32-bxcan.yaml
index 769fa5c27b76..de1d4298893b 100644
--- a/Documentation/devicetree/bindings/net/can/st,stm32-bxcan.yaml
+++ b/Documentation/devicetree/bindings/net/can/st,stm32-bxcan.yaml
@@ -21,11 +21,22 @@ properties:
 
   st,can-primary:
     description:
-      Primary and secondary mode of the bxCAN peripheral is only relevant
-      if the chip has two CAN peripherals. In that case they share some
-      of the required logic.
+      Primary mode of the bxCAN peripheral is only relevant if the chip has
+      two CAN peripherals in dual CAN configuration. In that case they share
+      some of the required logic.
+      Not to be used if the peripheral is in single CAN configuration.
       To avoid misunderstandings, it should be noted that ST documentation
-      uses the terms master/slave instead of primary/secondary.
+      uses the terms master instead of primary.
+    type: boolean
+
+  st,can-secondary:
+    description:
+      Secondary mode of the bxCAN peripheral is only relevant if the chip
+      has two CAN peripherals in dual CAN configuration. In that case they
+      share some of the required logic.
+      Not to be used if the peripheral is in single CAN configuration.
+      To avoid misunderstandings, it should be noted that ST documentation
+      uses the terms slave instead of secondary.
     type: boolean
 
   reg:
-- 
2.39.2



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

* [PATCH net 6/9] ARM: dts: stm32f429: put can2 in secondary mode
  2023-05-15 20:47 [PATCH net 0/9] pull-request: can 2023-05-15 Marc Kleine-Budde
                   ` (4 preceding siblings ...)
  2023-05-15 20:47 ` [PATCH net 5/9] dt-bindings: net: can: add "st,can-secondary" property Marc Kleine-Budde
@ 2023-05-15 20:47 ` Marc Kleine-Budde
  2023-05-15 20:47 ` [PATCH net 7/9] ARM: dts: stm32: add pin map for CAN controller on stm32f7 Marc Kleine-Budde
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2023-05-15 20:47 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Dario Binacchi, Marc Kleine-Budde

From: Dario Binacchi <dario.binacchi@amarulasolutions.com>

This is a preparation patch for the upcoming support to manage CAN
peripherals in single configuration.

The addition ensures backwards compatibility.

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Link: https://lore.kernel.org/all/20230427204540.3126234-3-dario.binacchi@amarulasolutions.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 arch/arm/boot/dts/stm32f429.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/stm32f429.dtsi b/arch/arm/boot/dts/stm32f429.dtsi
index c9e05e3540d6..00bf53f99c29 100644
--- a/arch/arm/boot/dts/stm32f429.dtsi
+++ b/arch/arm/boot/dts/stm32f429.dtsi
@@ -387,6 +387,7 @@ can2: can@40006800 {
 			interrupt-names = "tx", "rx0", "rx1", "sce";
 			resets = <&rcc STM32F4_APB1_RESET(CAN2)>;
 			clocks = <&rcc 0 STM32F4_APB1_CLOCK(CAN2)>;
+			st,can-secondary;
 			st,gcan = <&gcan>;
 			status = "disabled";
 		};
-- 
2.39.2



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

* [PATCH net 7/9] ARM: dts: stm32: add pin map for CAN controller on stm32f7
  2023-05-15 20:47 [PATCH net 0/9] pull-request: can 2023-05-15 Marc Kleine-Budde
                   ` (5 preceding siblings ...)
  2023-05-15 20:47 ` [PATCH net 6/9] ARM: dts: stm32f429: put can2 in secondary mode Marc Kleine-Budde
@ 2023-05-15 20:47 ` Marc Kleine-Budde
  2023-05-15 20:47 ` [PATCH net 8/9] can: bxcan: add support for single peripheral configuration Marc Kleine-Budde
  2023-05-15 20:47 ` [PATCH net 9/9] ARM: dts: stm32: add CAN support on stm32f746 Marc Kleine-Budde
  8 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2023-05-15 20:47 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Dario Binacchi, Marc Kleine-Budde

From: Dario Binacchi <dario.binacchi@amarulasolutions.com>

Add pin configurations for using CAN controller on stm32f7.

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Link: https://lore.kernel.org/all/20230427204540.3126234-4-dario.binacchi@amarulasolutions.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 arch/arm/boot/dts/stm32f7-pinctrl.dtsi | 82 ++++++++++++++++++++++++++
 1 file changed, 82 insertions(+)

diff --git a/arch/arm/boot/dts/stm32f7-pinctrl.dtsi b/arch/arm/boot/dts/stm32f7-pinctrl.dtsi
index c8e6c52fb248..9f65403295ca 100644
--- a/arch/arm/boot/dts/stm32f7-pinctrl.dtsi
+++ b/arch/arm/boot/dts/stm32f7-pinctrl.dtsi
@@ -283,6 +283,88 @@ pins2 {
 					slew-rate = <2>;
 				};
 			};
+
+			can1_pins_a: can1-0 {
+				pins1 {
+					pinmux = <STM32_PINMUX('A', 12, AF9)>; /* CAN1_TX */
+				};
+				pins2 {
+					pinmux = <STM32_PINMUX('A', 11, AF9)>; /* CAN1_RX */
+					bias-pull-up;
+				};
+			};
+
+			can1_pins_b: can1-1 {
+				pins1 {
+					pinmux = <STM32_PINMUX('B', 9, AF9)>; /* CAN1_TX */
+				};
+				pins2 {
+					pinmux = <STM32_PINMUX('B', 8, AF9)>; /* CAN1_RX */
+					bias-pull-up;
+				};
+			};
+
+			can1_pins_c: can1-2 {
+				pins1 {
+					pinmux = <STM32_PINMUX('D', 1, AF9)>; /* CAN1_TX */
+				};
+				pins2 {
+					pinmux = <STM32_PINMUX('D', 0, AF9)>; /* CAN1_RX */
+					bias-pull-up;
+
+				};
+			};
+
+			can1_pins_d: can1-3 {
+				pins1 {
+					pinmux = <STM32_PINMUX('H', 13, AF9)>; /* CAN1_TX */
+				};
+				pins2 {
+					pinmux = <STM32_PINMUX('H', 14, AF9)>; /* CAN1_RX */
+					bias-pull-up;
+
+				};
+			};
+
+			can2_pins_a: can2-0 {
+				pins1 {
+					pinmux = <STM32_PINMUX('B', 6, AF9)>; /* CAN2_TX */
+				};
+				pins2 {
+					pinmux = <STM32_PINMUX('B', 5, AF9)>; /* CAN2_RX */
+					bias-pull-up;
+				};
+			};
+
+			can2_pins_b: can2-1 {
+				pins1 {
+					pinmux = <STM32_PINMUX('B', 13, AF9)>; /* CAN2_TX */
+				};
+				pins2 {
+					pinmux = <STM32_PINMUX('B', 12, AF9)>; /* CAN2_RX */
+					bias-pull-up;
+				};
+			};
+
+			can3_pins_a: can3-0 {
+				pins1 {
+					pinmux = <STM32_PINMUX('A', 15, AF11)>; /* CAN3_TX */
+				};
+				pins2 {
+					pinmux = <STM32_PINMUX('A', 8, AF11)>; /* CAN3_RX */
+					bias-pull-up;
+				};
+			};
+
+			can3_pins_b: can3-1 {
+				pins1 {
+					pinmux = <STM32_PINMUX('B', 4, AF11)>;  /* CAN3_TX */
+				};
+				pins2 {
+					pinmux = <STM32_PINMUX('B', 3, AF11)>; /* CAN3_RX */
+					bias-pull-up;
+				};
+			};
 		};
 	};
 };
-- 
2.39.2



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

* [PATCH net 8/9] can: bxcan: add support for single peripheral configuration
  2023-05-15 20:47 [PATCH net 0/9] pull-request: can 2023-05-15 Marc Kleine-Budde
                   ` (6 preceding siblings ...)
  2023-05-15 20:47 ` [PATCH net 7/9] ARM: dts: stm32: add pin map for CAN controller on stm32f7 Marc Kleine-Budde
@ 2023-05-15 20:47 ` Marc Kleine-Budde
  2023-05-15 20:47 ` [PATCH net 9/9] ARM: dts: stm32: add CAN support on stm32f746 Marc Kleine-Budde
  8 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2023-05-15 20:47 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Dario Binacchi, Marc Kleine-Budde

From: Dario Binacchi <dario.binacchi@amarulasolutions.com>

Add support for bxCAN controller in single peripheral configuration:
- primary bxCAN
- dedicated Memory Access Controller unit
- 512-byte SRAM memory
- 14 filter banks

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Link: https://lore.kernel.org/all/20230427204540.3126234-5-dario.binacchi@amarulasolutions.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/bxcan.c | 34 +++++++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/drivers/net/can/bxcan.c b/drivers/net/can/bxcan.c
index e26ccd41e3cb..027a8a162fe4 100644
--- a/drivers/net/can/bxcan.c
+++ b/drivers/net/can/bxcan.c
@@ -118,7 +118,7 @@
 #define BXCAN_FiR1_REG(b) (0x40 + (b) * 8)
 #define BXCAN_FiR2_REG(b) (0x44 + (b) * 8)
 
-#define BXCAN_FILTER_ID(primary) (primary ? 0 : 14)
+#define BXCAN_FILTER_ID(cfg) ((cfg) == BXCAN_CFG_DUAL_SECONDARY ? 14 : 0)
 
 /* Filter primary register (FMR) bits */
 #define BXCAN_FMR_CANSB_MASK GENMASK(13, 8)
@@ -135,6 +135,12 @@ enum bxcan_lec_code {
 	BXCAN_LEC_UNUSED
 };
 
+enum bxcan_cfg {
+	BXCAN_CFG_SINGLE = 0,
+	BXCAN_CFG_DUAL_PRIMARY,
+	BXCAN_CFG_DUAL_SECONDARY
+};
+
 /* Structure of the message buffer */
 struct bxcan_mb {
 	u32 id;			/* can identifier */
@@ -167,7 +173,7 @@ struct bxcan_priv {
 	struct regmap *gcan;
 	int tx_irq;
 	int sce_irq;
-	bool primary;
+	enum bxcan_cfg cfg;
 	struct clk *clk;
 	spinlock_t rmw_lock;	/* lock for read-modify-write operations */
 	unsigned int tx_head;
@@ -202,17 +208,17 @@ static inline void bxcan_rmw(struct bxcan_priv *priv, void __iomem *addr,
 	spin_unlock_irqrestore(&priv->rmw_lock, flags);
 }
 
-static void bxcan_disable_filters(struct bxcan_priv *priv, bool primary)
+static void bxcan_disable_filters(struct bxcan_priv *priv, enum bxcan_cfg cfg)
 {
-	unsigned int fid = BXCAN_FILTER_ID(primary);
+	unsigned int fid = BXCAN_FILTER_ID(cfg);
 	u32 fmask = BIT(fid);
 
 	regmap_update_bits(priv->gcan, BXCAN_FA1R_REG, fmask, 0);
 }
 
-static void bxcan_enable_filters(struct bxcan_priv *priv, bool primary)
+static void bxcan_enable_filters(struct bxcan_priv *priv, enum bxcan_cfg cfg)
 {
-	unsigned int fid = BXCAN_FILTER_ID(primary);
+	unsigned int fid = BXCAN_FILTER_ID(cfg);
 	u32 fmask = BIT(fid);
 
 	/* Filter settings:
@@ -680,7 +686,7 @@ static int bxcan_chip_start(struct net_device *ndev)
 		  BXCAN_BTR_BRP_MASK | BXCAN_BTR_TS1_MASK | BXCAN_BTR_TS2_MASK |
 		  BXCAN_BTR_SJW_MASK, set);
 
-	bxcan_enable_filters(priv, priv->primary);
+	bxcan_enable_filters(priv, priv->cfg);
 
 	/* Clear all internal status */
 	priv->tx_head = 0;
@@ -806,7 +812,7 @@ static void bxcan_chip_stop(struct net_device *ndev)
 		  BXCAN_IER_EPVIE | BXCAN_IER_EWGIE | BXCAN_IER_FOVIE1 |
 		  BXCAN_IER_FFIE1 | BXCAN_IER_FMPIE1 | BXCAN_IER_FOVIE0 |
 		  BXCAN_IER_FFIE0 | BXCAN_IER_FMPIE0 | BXCAN_IER_TMEIE, 0);
-	bxcan_disable_filters(priv, priv->primary);
+	bxcan_disable_filters(priv, priv->cfg);
 	bxcan_enter_sleep_mode(priv);
 	priv->can.state = CAN_STATE_STOPPED;
 }
@@ -931,7 +937,7 @@ static int bxcan_probe(struct platform_device *pdev)
 	struct clk *clk = NULL;
 	void __iomem *regs;
 	struct regmap *gcan;
-	bool primary;
+	enum bxcan_cfg cfg;
 	int err, rx_irq, tx_irq, sce_irq;
 
 	regs = devm_platform_ioremap_resource(pdev, 0);
@@ -946,7 +952,13 @@ static int bxcan_probe(struct platform_device *pdev)
 		return PTR_ERR(gcan);
 	}
 
-	primary = of_property_read_bool(np, "st,can-primary");
+	if (of_property_read_bool(np, "st,can-primary"))
+		cfg = BXCAN_CFG_DUAL_PRIMARY;
+	else if (of_property_read_bool(np, "st,can-secondary"))
+		cfg = BXCAN_CFG_DUAL_SECONDARY;
+	else
+		cfg = BXCAN_CFG_SINGLE;
+
 	clk = devm_clk_get(dev, NULL);
 	if (IS_ERR(clk)) {
 		dev_err(dev, "failed to get clock\n");
@@ -992,7 +1004,7 @@ static int bxcan_probe(struct platform_device *pdev)
 	priv->clk = clk;
 	priv->tx_irq = tx_irq;
 	priv->sce_irq = sce_irq;
-	priv->primary = primary;
+	priv->cfg = cfg;
 	priv->can.clock.freq = clk_get_rate(clk);
 	spin_lock_init(&priv->rmw_lock);
 	priv->tx_head = 0;
-- 
2.39.2



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

* [PATCH net 9/9] ARM: dts: stm32: add CAN support on stm32f746
  2023-05-15 20:47 [PATCH net 0/9] pull-request: can 2023-05-15 Marc Kleine-Budde
                   ` (7 preceding siblings ...)
  2023-05-15 20:47 ` [PATCH net 8/9] can: bxcan: add support for single peripheral configuration Marc Kleine-Budde
@ 2023-05-15 20:47 ` Marc Kleine-Budde
  8 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2023-05-15 20:47 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Dario Binacchi, Marc Kleine-Budde

From: Dario Binacchi <dario.binacchi@amarulasolutions.com>

Add support for bxcan (Basic eXtended CAN controller) to STM32F746. The
chip contains three CAN peripherals, CAN1 and CAN2 in dual peripheral
configuration and CAN3 in single peripheral configuration:
- Dual CAN peripheral configuration:
  * CAN1: Primary bxCAN for managing the communication between a secondary
    bxCAN and the 512-byte SRAM memory.
  * CAN2: Secondary bxCAN with no direct access to the SRAM memory.
  This means that the two bxCAN cells share the 512-byte SRAM memory and
  CAN2 can't be used without enabling CAN1.
- Single CAN peripheral configuration:
  * CAN3: Primary bxCAN with dedicated Memory Access Controller unit and
    512-byte SRAM memory.

 -------------------------------------------------------------------------
| features | CAN1              | CAN2               | CAN 3               |
 -------------------------------------------------------------------------
| SRAM     | 512-byte shared between CAN1 & CAN2    | 512-byte            |
 -------------------------------------------------------------------------
| Filters  | 26 filters shared between CAN1 & CAN2  | 14 filters          |
 -------------------------------------------------------------------------

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Link: https://lore.kernel.org/all/20230427204540.3126234-6-dario.binacchi@amarulasolutions.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 arch/arm/boot/dts/stm32f746.dtsi | 47 ++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/arch/arm/boot/dts/stm32f746.dtsi b/arch/arm/boot/dts/stm32f746.dtsi
index dc868e6da40e..973698bc9ef4 100644
--- a/arch/arm/boot/dts/stm32f746.dtsi
+++ b/arch/arm/boot/dts/stm32f746.dtsi
@@ -257,6 +257,23 @@ rtc: rtc@40002800 {
 			status = "disabled";
 		};
 
+		can3: can@40003400 {
+			compatible = "st,stm32f4-bxcan";
+			reg = <0x40003400 0x200>;
+			interrupts = <104>, <105>, <106>, <107>;
+			interrupt-names = "tx", "rx0", "rx1", "sce";
+			resets = <&rcc STM32F7_APB1_RESET(CAN3)>;
+			clocks = <&rcc 0 STM32F7_APB1_CLOCK(CAN3)>;
+			st,gcan = <&gcan3>;
+			status = "disabled";
+		};
+
+		gcan3: gcan@40003600 {
+			compatible = "st,stm32f4-gcan", "syscon";
+			reg = <0x40003600 0x200>;
+			clocks = <&rcc 0 STM32F7_APB1_CLOCK(CAN3)>;
+		};
+
 		usart2: serial@40004400 {
 			compatible = "st,stm32f7-uart";
 			reg = <0x40004400 0x400>;
@@ -337,6 +354,36 @@ i2c4: i2c@40006000 {
 			status = "disabled";
 		};
 
+		can1: can@40006400 {
+			compatible = "st,stm32f4-bxcan";
+			reg = <0x40006400 0x200>;
+			interrupts = <19>, <20>, <21>, <22>;
+			interrupt-names = "tx", "rx0", "rx1", "sce";
+			resets = <&rcc STM32F7_APB1_RESET(CAN1)>;
+			clocks = <&rcc 0 STM32F7_APB1_CLOCK(CAN1)>;
+			st,can-primary;
+			st,gcan = <&gcan1>;
+			status = "disabled";
+		};
+
+		gcan1: gcan@40006600 {
+			compatible = "st,stm32f4-gcan", "syscon";
+			reg = <0x40006600 0x200>;
+			clocks = <&rcc 0 STM32F7_APB1_CLOCK(CAN1)>;
+		};
+
+		can2: can@40006800 {
+			compatible = "st,stm32f4-bxcan";
+			reg = <0x40006800 0x200>;
+			interrupts = <63>, <64>, <65>, <66>;
+			interrupt-names = "tx", "rx0", "rx1", "sce";
+			resets = <&rcc STM32F7_APB1_RESET(CAN2)>;
+			clocks = <&rcc 0 STM32F7_APB1_CLOCK(CAN2)>;
+			st,can-secondary;
+			st,gcan = <&gcan1>;
+			status = "disabled";
+		};
+
 		cec: cec@40006c00 {
 			compatible = "st,stm32-cec";
 			reg = <0x40006C00 0x400>;
-- 
2.39.2



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

* Re: [PATCH net 1/9] can: isotp: recvmsg(): allow MSG_CMSG_COMPAT flag
  2023-05-15 20:47 ` [PATCH net 1/9] can: isotp: recvmsg(): allow MSG_CMSG_COMPAT flag Marc Kleine-Budde
@ 2023-05-17  4:00   ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 11+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-05-17  4:00 UTC (permalink / raw)
  To: Marc Kleine-Budde
  Cc: netdev, davem, kuba, linux-can, kernel, socketcan, o.rempel,
	stable

Hello:

This series was applied to netdev/net.git (main)
by Marc Kleine-Budde <mkl@pengutronix.de>:

On Mon, 15 May 2023 22:47:14 +0200 you wrote:
> From: Oliver Hartkopp <socketcan@hartkopp.net>
> 
> The control message provided by isotp support MSG_CMSG_COMPAT but
> blocked recvmsg() syscalls that have set this flag, i.e. on 32bit user
> space on 64 bit kernels.
> 
> Link: https://github.com/hartkopp/can-isotp/issues/59
> Cc: Oleksij Rempel <o.rempel@pengutronix.de>
> Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
> Fixes: 42bf50a1795a ("can: isotp: support MSG_TRUNC flag when reading from socket")
> Link: https://lore.kernel.org/20230505110308.81087-2-mkl@pengutronix.de
> Cc: stable@vger.kernel.org
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> 
> [...]

Here is the summary with links:
  - [net,1/9] can: isotp: recvmsg(): allow MSG_CMSG_COMPAT flag
    https://git.kernel.org/netdev/net/c/db2773d65b02
  - [net,2/9] can: j1939: recvmsg(): allow MSG_CMSG_COMPAT flag
    https://git.kernel.org/netdev/net/c/1db080cbdbab
  - [net,3/9] can: dev: fix missing CAN XL support in can_put_echo_skb()
    https://git.kernel.org/netdev/net/c/6bffdc38f993
  - [net,4/9] can: CAN_BXCAN should depend on ARCH_STM32
    https://git.kernel.org/netdev/net/c/4920bded3ee0
  - [net,5/9] dt-bindings: net: can: add "st,can-secondary" property
    https://git.kernel.org/netdev/net/c/caf78f0f4919
  - [net,6/9] ARM: dts: stm32f429: put can2 in secondary mode
    https://git.kernel.org/netdev/net/c/6b443faa313c
  - [net,7/9] ARM: dts: stm32: add pin map for CAN controller on stm32f7
    https://git.kernel.org/netdev/net/c/011644249686
  - [net,8/9] can: bxcan: add support for single peripheral configuration
    https://git.kernel.org/netdev/net/c/85a79b971164
  - [net,9/9] ARM: dts: stm32: add CAN support on stm32f746
    https://git.kernel.org/netdev/net/c/0920ccdf41e3

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2023-05-17  4:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-15 20:47 [PATCH net 0/9] pull-request: can 2023-05-15 Marc Kleine-Budde
2023-05-15 20:47 ` [PATCH net 1/9] can: isotp: recvmsg(): allow MSG_CMSG_COMPAT flag Marc Kleine-Budde
2023-05-17  4:00   ` patchwork-bot+netdevbpf
2023-05-15 20:47 ` [PATCH net 2/9] can: j1939: " Marc Kleine-Budde
2023-05-15 20:47 ` [PATCH net 3/9] can: dev: fix missing CAN XL support in can_put_echo_skb() Marc Kleine-Budde
2023-05-15 20:47 ` [PATCH net 4/9] can: CAN_BXCAN should depend on ARCH_STM32 Marc Kleine-Budde
2023-05-15 20:47 ` [PATCH net 5/9] dt-bindings: net: can: add "st,can-secondary" property Marc Kleine-Budde
2023-05-15 20:47 ` [PATCH net 6/9] ARM: dts: stm32f429: put can2 in secondary mode Marc Kleine-Budde
2023-05-15 20:47 ` [PATCH net 7/9] ARM: dts: stm32: add pin map for CAN controller on stm32f7 Marc Kleine-Budde
2023-05-15 20:47 ` [PATCH net 8/9] can: bxcan: add support for single peripheral configuration Marc Kleine-Budde
2023-05-15 20:47 ` [PATCH net 9/9] ARM: dts: stm32: add CAN support on stm32f746 Marc Kleine-Budde

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).