From: Marc Kleine-Budde <mkl@pengutronix.de> Date: 2021-01-27 09:26:50
Hello Jakub, hello David,
this is a pull request of 12 patches for net-next/master.
The first two patches are by me and fix typos on the CAN gw protocol and the
flexcan driver.
The next patch is by Vincent Mailhol and targets the CAN driver infrastructure,
it exports the function that converts the CAN state into a human readable
string.
A patch by me, which target the CAN driver infrastructure, too, makes the
calculation in can_fd_len2dlc() more readable.
A patch by Tom Rix fixes a checkpatch warning in the mcba_usb driver.
The next seven patches target the mcp251xfd driver. Su Yanjun's patch replaces
several hardcoded assumptions when calling regmap, by using
regmap_get_val_bytes(). The remaining patches are by me. First an open coded
check is replaced by an existing helper function, then in the TX path the
padding for CAN-FD frames is cleaned up. The next two patches clean up the RTR
frame handling in the RX and TX path. Then support for len8_dlc is added. The
last patch adds BQL support.
regards,
Marc
---
The following changes since commit 6626a0266566c5aea16178c5e6cd7fc4db3f2f56:
Merge branch 'net-usbnet-convert-to-new-tasklet-api' (2021-01-26 18:04:28 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git tags/linux-can-next-for-5.12-20210127
for you to fetch changes up to 4162e18e949ba520d5116ac0323500355479a00e:
can: mcp251xfd: add BQL support (2021-01-27 10:01:47 +0100)
----------------------------------------------------------------
linux-can-next-for-5.12-20210127
----------------------------------------------------------------
Marc Kleine-Budde (9):
can: gw: fix typo
can: flexcan: fix typos
can: length: can_fd_len2dlc(): make legnth calculation readable again
can: mcp251xfd: mcp251xfd_start_xmit(): use mcp251xfd_get_tx_free() to check TX is is full
can: mcp251xfd: mcp251xfd_tx_obj_from_skb(): clean up padding of CAN-FD frames
can: mcp251xfd: mcp251xfd_hw_rx_obj_to_skb(): don't copy data for RTR CAN frames in RX-path
can: mcp251xfd: mcp251xfd_tx_obj_from_skb(): don't copy data for RTR CAN frames in TX-path
can: mcp251xfd: add len8_dlc support
can: mcp251xfd: add BQL support
Su Yanjun (1):
can: mcp251xfd: replace sizeof(u32) with val_bytes in regmap
Tom Rix (1):
can: mcba_usb: remove h from printk format specifier
Vincent Mailhol (1):
can: dev: export can_get_state_str() function
drivers/net/can/dev/dev.c | 3 +-
drivers/net/can/dev/length.c | 7 ++-
drivers/net/can/flexcan.c | 4 +-
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 79 ++++++++++++++++++--------
drivers/net/can/usb/mcba_usb.c | 6 +-
include/linux/can/dev.h | 1 +
net/can/gw.c | 2 +-
7 files changed, 70 insertions(+), 32 deletions(-)
From: Marc Kleine-Budde <mkl@pengutronix.de> Date: 2021-01-27 09:26:49
This patch fixes two typos found by codespell.
Fixes: 812f0116c66a ("can: flexcan: add CAN wakeup function for i.MX8QM")
Link: https://lore.kernel.org/r/20210127085529.2768537-2-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/flexcan.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
@@ -1975,14 +1975,14 @@ static int flexcan_setup_stop_mode_scfw(struct platform_device *pdev)priv=netdev_priv(dev);priv->scu_idx=scu_idx;-/* this function could be defered probe, return -EPROBE_DEFER */+/* this function could be deferred probe, return -EPROBE_DEFER */returnimx_scu_get_handle(&priv->sc_ipc_handle);}/* flexcan_setup_stop_mode - Setup stop mode for wakeup**Return:=0setupstopmodesuccessfullyordoesn'tsupportthisfeature-*<0failtosetupstopmode(couldbedeferedprobe)+*<0failtosetupstopmode(couldbedeferredprobe)*/staticintflexcan_setup_stop_mode(structplatform_device*pdev){
From: Marc Kleine-Budde <mkl@pengutronix.de> Date: 2021-01-27 09:27:02
This patch replaces an open coded check if the TX ring is full by a check if
mcp251xfd_get_tx_free() returns 0.
Link: https://lore.kernel.org/r/20210114153448.1506901-2-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Marc Kleine-Budde <mkl@pengutronix.de> Date: 2021-01-27 09:27:50
In Classical CAN there are RTR frames. RTR frames have the RTR bit set, may
have a dlc != 0, but contain no data.
This patch changes the RX-path to no copy any data for RTR frames, so that the
data field in the CAN frame stays 0x0.
Link: https://lore.kernel.org/r/20210114153448.1506901-4-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
From: Marc Kleine-Budde <mkl@pengutronix.de> Date: 2021-01-27 09:28:22
From: Vincent Mailhol <redacted>
The can_get_state_str() function is also relevant to the drivers. Export the
symbol and make it visible in the can/dev.h header.
Link: https://lore.kernel.org/r/20210119170355.12040-1-mailhol.vincent@wanadoo.fr
Signed-off-by: Vincent Mailhol <redacted>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/dev/dev.c | 3 ++-
include/linux/can/dev.h | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
From: Marc Kleine-Budde <mkl@pengutronix.de> Date: 2021-01-27 09:28:22
In commit 652562e5ff06 ("can: length: can_fd_len2dlc(): simplify length
calculcation") the readability of the code degraded and became more error
prone. To counteract this, partially convert that patch and replace open coded
values (of the original code) with proper defines.
Fixes: 652562e5ff06 ("can: length: can_fd_len2dlc(): simplify length calculcation")
Cc: Vincent MAILHOL <redacted>
Link: https://lore.kernel.org/r/20210118201346.79422-1-socketcan@hartkopp.net
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/dev/length.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
From: Marc Kleine-Budde <mkl@pengutronix.de> Date: 2021-01-27 09:28:22
This patch adds BQL support to the driver. Support for netdev_xmit_more() will
be added in a separate patch series.
Link: https://lore.kernel.org/r/20210114153448.1506901-7-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
.../net/can/spi/mcp251xfd/mcp251xfd-core.c | 21 +++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
@@ -1350,7 +1355,9 @@ static int mcp251xfd_handle_tefif(struct mcp251xfd_priv *priv)}for(i=0;i<len;i++){-err=mcp251xfd_handle_tefif_one(priv,&hw_tef_obj[i]);+unsignedintframe_len;++err=mcp251xfd_handle_tefif_one(priv,&hw_tef_obj[i],&frame_len);/* -EAGAIN means the Sequence Number in the TEF*doesn'tmatchourtef_tail.Thiscanhappenifwe*readtheTEFobjectstooearly.Leaveloopletthe
@@ -1360,6 +1367,8 @@ static int mcp251xfd_handle_tefif(struct mcp251xfd_priv *priv)gotoout_netif_wake_queue;if(err)returnerr;++total_frame_len+=frame_len;}out_netif_wake_queue:
@@ -1390,6 +1399,7 @@ static int mcp251xfd_handle_tefif(struct mcp251xfd_priv *priv)returnerr;tx_ring->tail+=len;+netdev_completed_queue(priv->ndev,len,total_frame_len);err=mcp251xfd_check_tef_tail(priv);if(err)
From: Marc Kleine-Budde <mkl@pengutronix.de> Date: 2021-01-27 09:28:28
This patch adds support for the Classical CAN raw DLC functionality to send and
receive DLC values from 9 ... 15 to the mcp251xfd driver.
Link: https://lore.kernel.org/r/20210114153448.1506901-6-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
.../net/can/spi/mcp251xfd/mcp251xfd-core.c | 23 ++++++++++++-------
1 file changed, 15 insertions(+), 8 deletions(-)
From: Marc Kleine-Budde <mkl@pengutronix.de> Date: 2021-01-27 09:29:29
From: Su Yanjun <redacted>
The sizeof(u32) is hardcoded. It's better to use the config value from the
regmap.
It increases the size of target object, but it's flexible when new mcp chip
need other val_bytes.
Link: https://lore.kernel.org/r/20210122081334.213957-1-suyanjun218@gmail.com
Signed-off-by: Su Yanjun <redacted>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
From: Marc Kleine-Budde <mkl@pengutronix.de> Date: 2021-01-27 09:30:13
From: Tom Rix <trix@redhat.com>
This change fixes the checkpatch warning described in this commit commit
cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use of unnecessary
%h[xudi] and %hh[xudi]")
Standard integer promotion is already done and %hx and %hhx is useless so do
not encourage the use of %hh[xudi] or %h[xudi].
Link: https://lore.kernel.org/r/20210124150916.1920434-1-trix@redhat.com
Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/usb/mcba_usb.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
@@ -466,7 +466,7 @@ static void mcba_usb_process_ka_usb(struct mcba_priv *priv,structmcba_usb_msg_ka_usb*msg){if(unlikely(priv->usb_ka_first_pass)){-netdev_info(priv->netdev,"PIC USB version %hhu.%hhu\n",+netdev_info(priv->netdev,"PIC USB version %u.%u\n",msg->soft_ver_major,msg->soft_ver_minor);priv->usb_ka_first_pass=false;
@@ -492,7 +492,7 @@ static void mcba_usb_process_ka_can(struct mcba_priv *priv,structmcba_usb_msg_ka_can*msg){if(unlikely(priv->can_ka_first_pass)){-netdev_info(priv->netdev,"PIC CAN version %hhu.%hhu\n",+netdev_info(priv->netdev,"PIC CAN version %u.%u\n",msg->soft_ver_major,msg->soft_ver_minor);priv->can_ka_first_pass=false;
From: Marc Kleine-Budde <mkl@pengutronix.de> Date: 2021-01-27 09:30:13
This patch fixes a typo found by codespell.
Fixes: 94c23097f991 ("can: gw: support modification of Classical CAN DLCs")
Link: https://lore.kernel.org/r/20210127085529.2768537-3-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
net/can/gw.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Marc Kleine-Budde <mkl@pengutronix.de> Date: 2021-01-27 09:30:13
CAN-FD frames have only specific frame length (0, 1, 2, 3, 4, 5, 6, 7, 8, 12,
16, 20, 24, 32, 48, 64). A CAN-FD frame provided by user space might not cover
the whole CAN-FD frame. To avoid sending garbage over the CAN bus the driver
pads the CAN frame with 0x0 (if MCP251XFD_SANITIZE_CAN is activated).
This patch cleans up the pad len calculation. Rounding to full u32 brings no
benefit, in case of CRC transfers, the hw_tx_obj->data is not aligned to u32
anyway.
Link: https://lore.kernel.org/r/20210114153448.1506901-3-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
@@ -2351,13 +2351,14 @@ mcp251xfd_tx_obj_from_skb(const struct mcp251xfd_priv *priv,put_unaligned_le32(id,&hw_tx_obj->id);put_unaligned_le32(flags,&hw_tx_obj->flags);-/* Clear data at end of CAN frame */-offset=round_down(cfd->len,sizeof(u32));-len=round_up(can_fd_dlc2len(dlc),sizeof(u32))-offset;-if(MCP251XFD_SANITIZE_CAN&&len)-memset(hw_tx_obj->data+offset,0x0,len);+/* Copy data */memcpy(hw_tx_obj->data,cfd->data,cfd->len);+/* Clear unused data at end of CAN frame */+pad_len=can_fd_dlc2len(dlc)-cfd->len;+if(MCP251XFD_SANITIZE_CAN&&pad_len)+memset(hw_tx_obj->data+cfd->len,0x0,pad_len);+/* Number of bytes to be written into the RAM of the controller */len=sizeof(hw_tx_obj->id)+sizeof(hw_tx_obj->flags);if(MCP251XFD_SANITIZE_CAN)
From: Marc Kleine-Budde <mkl@pengutronix.de> Date: 2021-01-27 09:48:26
In Classical CAN there are RTR frames. RTR frames have the RTR bit set, may
have a dlc != 0, but contain no data.
This patch optimizes the TX-path to not copy any data for RTR frames.
Link: https://lore.kernel.org/r/20210114153448.1506901-5-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
@@ -2356,14 +2358,18 @@ mcp251xfd_tx_obj_from_skb(const struct mcp251xfd_priv *priv,memcpy(hw_tx_obj->data,cfd->data,cfd->len);/* Clear unused data at end of CAN frame */-pad_len=can_fd_dlc2len(dlc)-cfd->len;-if(MCP251XFD_SANITIZE_CAN&&pad_len)-memset(hw_tx_obj->data+cfd->len,0x0,pad_len);+if(MCP251XFD_SANITIZE_CAN&&len_sanitized){+intpad_len;++pad_len=len_sanitized-cfd->len;+if(pad_len)+memset(hw_tx_obj->data+cfd->len,0x0,pad_len);+}/* Number of bytes to be written into the RAM of the controller */len=sizeof(hw_tx_obj->id)+sizeof(hw_tx_obj->flags);if(MCP251XFD_SANITIZE_CAN)-len+=round_up(can_fd_dlc2len(dlc),sizeof(u32));+len+=round_up(len_sanitized,sizeof(u32));elselen+=round_up(cfd->len,sizeof(u32));
Hello:
This pull request was applied to netdev/net-next.git (refs/heads/master):
On Wed, 27 Jan 2021 10:22:15 +0100 you wrote:
Hello Jakub, hello David,
this is a pull request of 12 patches for net-next/master.
The first two patches are by me and fix typos on the CAN gw protocol and the
flexcan driver.
[...]
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
On Wed, 27 Jan 2021 10:22:16 +0100 you wrote:
This patch fixes a typo found by codespell.
Fixes: 94c23097f991 ("can: gw: support modification of Classical CAN DLCs")
Link: https://lore.kernel.org/r/20210127085529.2768537-3-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
net/can/gw.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[...]