Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'linux-can-fixes-for-7.0-20260302' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can

Marc Kleine-Budde says:

====================
pull-request: can 2026-03-02

The first 2 patches are by Oliver Hartkopp. The first fixes the
locking for CAN Broadcast Manager op runtime updates, the second fixes
the packet statisctics for the CAN dummy driver.

Alban Bedel's patch fixes a potential problem in the error path of the
mcp251x's ndo_open callback.

A patch by Ziyi Guo add USB endpoint type validation to the esd_usb
driver.

The next 6 patches are by Greg Kroah-Hartman and fix URB data parsing
for the ems_usb and ucan driver, fix URB anchoring in the etas_es58x,
and in the f81604 driver fix URB data parsing, add URB error handling
and fix URB anchoring.

A patch by me targets the gs_usb driver and fixes interoperability
with the CANable-2.5 firmware by always configuring the bit rate
before starting the device.

The last patch is by Frank Li and fixes a CHECK_DTBS warning for the
nxp,sja1000 dt-binding.

* tag 'linux-can-fixes-for-7.0-20260302' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can:
dt-bindings: net: can: nxp,sja1000: add reference to mc-peripheral-props.yaml
can: gs_usb: gs_can_open(): always configure bitrates before starting device
can: usb: f81604: correctly anchor the urb in the read bulk callback
can: usb: f81604: handle bulk write errors properly
can: usb: f81604: handle short interrupt urb messages properly
can: usb: etas_es58x: correctly anchor the urb in the read bulk callback
can: ucan: Fix infinite loop from zero-length messages
can: ems_usb: ems_usb_read_bulk_callback(): check the proper length of a message
can: esd_usb: add endpoint type validation
can: mcp251x: fix deadlock in error path of mcp251x_open
can: dummy_can: dummy_can_init(): fix packet statistics
can: bcm: fix locking for bcm_op runtime updates
====================

Link: https://patch.msgid.link/20260302152755.1700177-1-mkl@pengutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+104 -28
+1
Documentation/devicetree/bindings/net/can/nxp,sja1000.yaml
··· 87 87 88 88 allOf: 89 89 - $ref: can-controller.yaml# 90 + - $ref: /schemas/memory-controllers/mc-peripheral-props.yaml 90 91 - if: 91 92 properties: 92 93 compatible:
+1
drivers/net/can/dummy_can.c
··· 241 241 242 242 dev->netdev_ops = &dummy_can_netdev_ops; 243 243 dev->ethtool_ops = &dummy_can_ethtool_ops; 244 + dev->flags |= IFF_ECHO; /* enable echo handling */ 244 245 priv = netdev_priv(dev); 245 246 priv->can.bittiming_const = &dummy_can_bittiming_const; 246 247 priv->can.bitrate_max = 20 * MEGA /* BPS */;
+14 -1
drivers/net/can/spi/mcp251x.c
··· 1214 1214 { 1215 1215 struct mcp251x_priv *priv = netdev_priv(net); 1216 1216 struct spi_device *spi = priv->spi; 1217 + bool release_irq = false; 1217 1218 unsigned long flags = 0; 1218 1219 int ret; 1219 1220 ··· 1258 1257 return 0; 1259 1258 1260 1259 out_free_irq: 1261 - free_irq(spi->irq, priv); 1260 + /* The IRQ handler might be running, and if so it will be waiting 1261 + * for the lock. But free_irq() must wait for the handler to finish 1262 + * so calling it here would deadlock. 1263 + * 1264 + * Setting priv->force_quit will let the handler exit right away 1265 + * without any access to the hardware. This make it safe to call 1266 + * free_irq() after the lock is released. 1267 + */ 1268 + priv->force_quit = 1; 1269 + release_irq = true; 1270 + 1262 1271 mcp251x_hw_sleep(spi); 1263 1272 out_close: 1264 1273 mcp251x_power_enable(priv->transceiver, 0); 1265 1274 close_candev(net); 1266 1275 mutex_unlock(&priv->mcp_lock); 1276 + if (release_irq) 1277 + free_irq(spi->irq, priv); 1267 1278 return ret; 1268 1279 } 1269 1280
+6 -1
drivers/net/can/usb/ems_usb.c
··· 445 445 start = CPC_HEADER_SIZE; 446 446 447 447 while (msg_count) { 448 + if (start + CPC_MSG_HEADER_LEN > urb->actual_length) { 449 + netdev_err(netdev, "format error\n"); 450 + break; 451 + } 452 + 448 453 msg = (struct ems_cpc_msg *)&ibuf[start]; 449 454 450 455 switch (msg->type) { ··· 479 474 start += CPC_MSG_HEADER_LEN + msg->length; 480 475 msg_count--; 481 476 482 - if (start > urb->transfer_buffer_length) { 477 + if (start > urb->actual_length) { 483 478 netdev_err(netdev, "format error\n"); 484 479 break; 485 480 }
+17 -13
drivers/net/can/usb/esd_usb.c
··· 272 272 273 273 struct usb_anchor rx_submitted; 274 274 275 + unsigned int rx_pipe; 276 + unsigned int tx_pipe; 277 + 275 278 int net_count; 276 279 u32 version; 277 280 int rxinitdone; ··· 540 537 } 541 538 542 539 resubmit_urb: 543 - usb_fill_bulk_urb(urb, dev->udev, usb_rcvbulkpipe(dev->udev, 1), 540 + usb_fill_bulk_urb(urb, dev->udev, dev->rx_pipe, 544 541 urb->transfer_buffer, ESD_USB_RX_BUFFER_SIZE, 545 542 esd_usb_read_bulk_callback, dev); 546 543 ··· 629 626 { 630 627 int actual_length; 631 628 632 - return usb_bulk_msg(dev->udev, 633 - usb_sndbulkpipe(dev->udev, 2), 634 - msg, 629 + return usb_bulk_msg(dev->udev, dev->tx_pipe, msg, 635 630 msg->hdr.len * sizeof(u32), /* convert to # of bytes */ 636 631 &actual_length, 637 632 1000); ··· 640 639 { 641 640 int actual_length; 642 641 643 - return usb_bulk_msg(dev->udev, 644 - usb_rcvbulkpipe(dev->udev, 1), 645 - msg, 646 - sizeof(*msg), 647 - &actual_length, 648 - 1000); 642 + return usb_bulk_msg(dev->udev, dev->rx_pipe, msg, 643 + sizeof(*msg), &actual_length, 1000); 649 644 } 650 645 651 646 static int esd_usb_setup_rx_urbs(struct esd_usb *dev) ··· 674 677 675 678 urb->transfer_dma = buf_dma; 676 679 677 - usb_fill_bulk_urb(urb, dev->udev, 678 - usb_rcvbulkpipe(dev->udev, 1), 680 + usb_fill_bulk_urb(urb, dev->udev, dev->rx_pipe, 679 681 buf, ESD_USB_RX_BUFFER_SIZE, 680 682 esd_usb_read_bulk_callback, dev); 681 683 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; ··· 899 903 /* hnd must not be 0 - MSB is stripped in txdone handling */ 900 904 msg->tx.hnd = BIT(31) | i; /* returned in TX done message */ 901 905 902 - usb_fill_bulk_urb(urb, dev->udev, usb_sndbulkpipe(dev->udev, 2), buf, 906 + usb_fill_bulk_urb(urb, dev->udev, dev->tx_pipe, buf, 903 907 msg->hdr.len * sizeof(u32), /* convert to # of bytes */ 904 908 esd_usb_write_bulk_callback, context); 905 909 ··· 1294 1298 static int esd_usb_probe(struct usb_interface *intf, 1295 1299 const struct usb_device_id *id) 1296 1300 { 1301 + struct usb_endpoint_descriptor *ep_in, *ep_out; 1297 1302 struct esd_usb *dev; 1298 1303 union esd_usb_msg *msg; 1299 1304 int i, err; 1305 + 1306 + err = usb_find_common_endpoints(intf->cur_altsetting, &ep_in, &ep_out, 1307 + NULL, NULL); 1308 + if (err) 1309 + return err; 1300 1310 1301 1311 dev = kzalloc_obj(*dev); 1302 1312 if (!dev) { ··· 1311 1309 } 1312 1310 1313 1311 dev->udev = interface_to_usbdev(intf); 1312 + dev->rx_pipe = usb_rcvbulkpipe(dev->udev, ep_in->bEndpointAddress); 1313 + dev->tx_pipe = usb_sndbulkpipe(dev->udev, ep_out->bEndpointAddress); 1314 1314 1315 1315 init_usb_anchor(&dev->rx_submitted); 1316 1316
+7 -1
drivers/net/can/usb/etas_es58x/es58x_core.c
··· 1461 1461 } 1462 1462 1463 1463 resubmit_urb: 1464 + usb_anchor_urb(urb, &es58x_dev->rx_urbs); 1464 1465 ret = usb_submit_urb(urb, GFP_ATOMIC); 1466 + if (!ret) 1467 + return; 1468 + 1469 + usb_unanchor_urb(urb); 1470 + 1465 1471 if (ret == -ENODEV) { 1466 1472 for (i = 0; i < es58x_dev->num_can_ch; i++) 1467 1473 if (es58x_dev->netdev[i]) 1468 1474 netif_device_detach(es58x_dev->netdev[i]); 1469 - } else if (ret) 1475 + } else 1470 1476 dev_err_ratelimited(dev, 1471 1477 "Failed resubmitting read bulk urb: %pe\n", 1472 1478 ERR_PTR(ret));
+40 -5
drivers/net/can/usb/f81604.c
··· 413 413 { 414 414 struct f81604_can_frame *frame = urb->transfer_buffer; 415 415 struct net_device *netdev = urb->context; 416 + struct f81604_port_priv *priv = netdev_priv(netdev); 416 417 int ret; 417 418 418 419 if (!netif_device_present(netdev)) ··· 446 445 f81604_process_rx_packet(netdev, frame); 447 446 448 447 resubmit_urb: 448 + usb_anchor_urb(urb, &priv->urbs_anchor); 449 449 ret = usb_submit_urb(urb, GFP_ATOMIC); 450 + if (!ret) 451 + return; 452 + usb_unanchor_urb(urb); 453 + 450 454 if (ret == -ENODEV) 451 455 netif_device_detach(netdev); 452 - else if (ret) 456 + else 453 457 netdev_err(netdev, 454 458 "%s: failed to resubmit read bulk urb: %pe\n", 455 459 __func__, ERR_PTR(ret)); ··· 626 620 netdev_info(netdev, "%s: Int URB aborted: %pe\n", __func__, 627 621 ERR_PTR(urb->status)); 628 622 623 + if (urb->actual_length < sizeof(*data)) { 624 + netdev_warn(netdev, "%s: short int URB: %u < %zu\n", 625 + __func__, urb->actual_length, sizeof(*data)); 626 + goto resubmit_urb; 627 + } 628 + 629 629 switch (urb->status) { 630 630 case 0: /* success */ 631 631 break; ··· 658 646 f81604_handle_tx(priv, data); 659 647 660 648 resubmit_urb: 649 + usb_anchor_urb(urb, &priv->urbs_anchor); 661 650 ret = usb_submit_urb(urb, GFP_ATOMIC); 651 + if (!ret) 652 + return; 653 + usb_unanchor_urb(urb); 654 + 662 655 if (ret == -ENODEV) 663 656 netif_device_detach(netdev); 664 - else if (ret) 657 + else 665 658 netdev_err(netdev, "%s: failed to resubmit int urb: %pe\n", 666 659 __func__, ERR_PTR(ret)); 667 660 } ··· 891 874 if (!netif_device_present(netdev)) 892 875 return; 893 876 894 - if (urb->status) 895 - netdev_info(netdev, "%s: Tx URB error: %pe\n", __func__, 896 - ERR_PTR(urb->status)); 877 + if (!urb->status) 878 + return; 879 + 880 + switch (urb->status) { 881 + case -ENOENT: 882 + case -ECONNRESET: 883 + case -ESHUTDOWN: 884 + return; 885 + default: 886 + break; 887 + } 888 + 889 + if (net_ratelimit()) 890 + netdev_err(netdev, "%s: Tx URB error: %pe\n", __func__, 891 + ERR_PTR(urb->status)); 892 + 893 + can_free_echo_skb(netdev, 0, NULL); 894 + netdev->stats.tx_dropped++; 895 + netdev->stats.tx_errors++; 896 + 897 + netif_wake_queue(netdev); 897 898 } 898 899 899 900 static void f81604_clear_reg_work(struct work_struct *work)
+16 -6
drivers/net/can/usb/gs_usb.c
··· 772 772 } 773 773 } 774 774 775 - static int gs_usb_set_bittiming(struct net_device *netdev) 775 + static int gs_usb_set_bittiming(struct gs_can *dev) 776 776 { 777 - struct gs_can *dev = netdev_priv(netdev); 778 777 struct can_bittiming *bt = &dev->can.bittiming; 779 778 struct gs_device_bittiming dbt = { 780 779 .prop_seg = cpu_to_le32(bt->prop_seg), ··· 790 791 GFP_KERNEL); 791 792 } 792 793 793 - static int gs_usb_set_data_bittiming(struct net_device *netdev) 794 + static int gs_usb_set_data_bittiming(struct gs_can *dev) 794 795 { 795 - struct gs_can *dev = netdev_priv(netdev); 796 796 struct can_bittiming *bt = &dev->can.fd.data_bittiming; 797 797 struct gs_device_bittiming dbt = { 798 798 .prop_seg = cpu_to_le32(bt->prop_seg), ··· 1054 1056 /* if hardware supports timestamps, enable it */ 1055 1057 if (dev->feature & GS_CAN_FEATURE_HW_TIMESTAMP) 1056 1058 flags |= GS_CAN_MODE_HW_TIMESTAMP; 1059 + 1060 + rc = gs_usb_set_bittiming(dev); 1061 + if (rc) { 1062 + netdev_err(netdev, "failed to set bittiming: %pe\n", ERR_PTR(rc)); 1063 + goto out_usb_kill_anchored_urbs; 1064 + } 1065 + 1066 + if (ctrlmode & CAN_CTRLMODE_FD) { 1067 + rc = gs_usb_set_data_bittiming(dev); 1068 + if (rc) { 1069 + netdev_err(netdev, "failed to set data bittiming: %pe\n", ERR_PTR(rc)); 1070 + goto out_usb_kill_anchored_urbs; 1071 + } 1072 + } 1057 1073 1058 1074 /* finally start device */ 1059 1075 dev->can.state = CAN_STATE_ERROR_ACTIVE; ··· 1382 1370 dev->can.state = CAN_STATE_STOPPED; 1383 1371 dev->can.clock.freq = le32_to_cpu(bt_const.fclk_can); 1384 1372 dev->can.bittiming_const = &dev->bt_const; 1385 - dev->can.do_set_bittiming = gs_usb_set_bittiming; 1386 1373 1387 1374 dev->can.ctrlmode_supported = CAN_CTRLMODE_CC_LEN8_DLC; 1388 1375 ··· 1405 1394 * GS_CAN_FEATURE_BT_CONST_EXT is set. 1406 1395 */ 1407 1396 dev->can.fd.data_bittiming_const = &dev->bt_const; 1408 - dev->can.fd.do_set_data_bittiming = gs_usb_set_data_bittiming; 1409 1397 } 1410 1398 1411 1399 if (feature & GS_CAN_FEATURE_TERMINATION) {
+1 -1
drivers/net/can/usb/ucan.c
··· 748 748 len = le16_to_cpu(m->len); 749 749 750 750 /* check sanity (length of content) */ 751 - if (urb->actual_length - pos < len) { 751 + if ((len == 0) || (urb->actual_length - pos < len)) { 752 752 netdev_warn(up->netdev, 753 753 "invalid message (short; no data; l:%d)\n", 754 754 urb->actual_length);
+1
net/can/bcm.c
··· 1176 1176 if (!op) 1177 1177 return -ENOMEM; 1178 1178 1179 + spin_lock_init(&op->bcm_tx_lock); 1179 1180 op->can_id = msg_head->can_id; 1180 1181 op->nframes = msg_head->nframes; 1181 1182 op->cfsiz = CFSIZ(msg_head->flags);