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-5.12-20210301' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can

Marc Kleine-Budde says:

====================
pull-request: can 2021-03-01

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

The first 3 patches are by Joakim Zhang for the flexcan driver and fix
the probing and starting of the chip.

The next patch is by me, for the mcp251xfd driver and reverts the BQL
support. BQL support got mainline with rc1 and assumes that CAN frames
are always echoed, which is not the case. A proper fix requires
changes more changes and will be rolled out via linux-can-next later.

Oleksij Rempel's patch fixes the socket ref counting if socket was
closed before setting skb ownership.

Torin Cooper-Bennun's patch for the tcan4x5x driver fixes a race
condition, where the chip is first attached the bus and then the MRAM
is initialized, which may result in lost data.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+28 -31
+15 -9
drivers/net/can/flexcan.c
··· 701 701 u32 reg; 702 702 703 703 reg = priv->read(&regs->mcr); 704 - reg |= FLEXCAN_MCR_HALT; 704 + reg |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_HALT; 705 705 priv->write(reg, &regs->mcr); 706 706 707 707 while (timeout-- && !(priv->read(&regs->mcr) & FLEXCAN_MCR_FRZ_ACK)) ··· 1480 1480 1481 1481 flexcan_set_bittiming(dev); 1482 1482 1483 + /* set freeze, halt */ 1484 + err = flexcan_chip_freeze(priv); 1485 + if (err) 1486 + goto out_chip_disable; 1487 + 1483 1488 /* MCR 1484 1489 * 1485 - * enable freeze 1486 - * halt now 1487 1490 * only supervisor access 1488 1491 * enable warning int 1489 1492 * enable individual RX masking ··· 1495 1492 */ 1496 1493 reg_mcr = priv->read(&regs->mcr); 1497 1494 reg_mcr &= ~FLEXCAN_MCR_MAXMB(0xff); 1498 - reg_mcr |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_HALT | FLEXCAN_MCR_SUPV | 1499 - FLEXCAN_MCR_WRN_EN | FLEXCAN_MCR_IRMQ | FLEXCAN_MCR_IDAM_C | 1500 - FLEXCAN_MCR_MAXMB(priv->tx_mb_idx); 1495 + reg_mcr |= FLEXCAN_MCR_SUPV | FLEXCAN_MCR_WRN_EN | FLEXCAN_MCR_IRMQ | 1496 + FLEXCAN_MCR_IDAM_C | FLEXCAN_MCR_MAXMB(priv->tx_mb_idx); 1501 1497 1502 1498 /* MCR 1503 1499 * ··· 1867 1865 if (err) 1868 1866 goto out_chip_disable; 1869 1867 1870 - /* set freeze, halt and activate FIFO, restrict register access */ 1868 + /* set freeze, halt */ 1869 + err = flexcan_chip_freeze(priv); 1870 + if (err) 1871 + goto out_chip_disable; 1872 + 1873 + /* activate FIFO, restrict register access */ 1871 1874 reg = priv->read(&regs->mcr); 1872 - reg |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_HALT | 1873 - FLEXCAN_MCR_FEN | FLEXCAN_MCR_SUPV; 1875 + reg |= FLEXCAN_MCR_FEN | FLEXCAN_MCR_SUPV; 1874 1876 priv->write(reg, &regs->mcr); 1875 1877 1876 1878 /* Currently we only support newer versions of this core
+3 -3
drivers/net/can/m_can/tcan4x5x-core.c
··· 237 237 if (ret) 238 238 return ret; 239 239 240 + /* Zero out the MCAN buffers */ 241 + m_can_init_ram(cdev); 242 + 240 243 ret = regmap_update_bits(tcan4x5x->regmap, TCAN4X5X_CONFIG, 241 244 TCAN4X5X_MODE_SEL_MASK, TCAN4X5X_MODE_NORMAL); 242 245 if (ret) 243 246 return ret; 244 - 245 - /* Zero out the MCAN buffers */ 246 - m_can_init_ram(cdev); 247 247 248 248 return ret; 249 249 }
+4 -17
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
··· 335 335 u8 len; 336 336 int i, j; 337 337 338 - netdev_reset_queue(priv->ndev); 339 - 340 338 /* TEF */ 341 339 tef_ring = priv->tef; 342 340 tef_ring->head = 0; ··· 1247 1249 1248 1250 static int 1249 1251 mcp251xfd_handle_tefif_one(struct mcp251xfd_priv *priv, 1250 - const struct mcp251xfd_hw_tef_obj *hw_tef_obj, 1251 - unsigned int *frame_len_ptr) 1252 + const struct mcp251xfd_hw_tef_obj *hw_tef_obj) 1252 1253 { 1253 1254 struct net_device_stats *stats = &priv->ndev->stats; 1254 1255 u32 seq, seq_masked, tef_tail_masked; ··· 1269 1272 stats->tx_bytes += 1270 1273 can_rx_offload_get_echo_skb(&priv->offload, 1271 1274 mcp251xfd_get_tef_tail(priv), 1272 - hw_tef_obj->ts, 1273 - frame_len_ptr); 1275 + hw_tef_obj->ts, NULL); 1274 1276 stats->tx_packets++; 1275 1277 priv->tef->tail++; 1276 1278 ··· 1327 1331 static int mcp251xfd_handle_tefif(struct mcp251xfd_priv *priv) 1328 1332 { 1329 1333 struct mcp251xfd_hw_tef_obj hw_tef_obj[MCP251XFD_TX_OBJ_NUM_MAX]; 1330 - unsigned int total_frame_len = 0; 1331 1334 u8 tef_tail, len, l; 1332 1335 int err, i; 1333 1336 ··· 1348 1353 } 1349 1354 1350 1355 for (i = 0; i < len; i++) { 1351 - unsigned int frame_len; 1352 - 1353 - err = mcp251xfd_handle_tefif_one(priv, &hw_tef_obj[i], &frame_len); 1356 + err = mcp251xfd_handle_tefif_one(priv, &hw_tef_obj[i]); 1354 1357 /* -EAGAIN means the Sequence Number in the TEF 1355 1358 * doesn't match our tef_tail. This can happen if we 1356 1359 * read the TEF objects too early. Leave loop let the ··· 1358 1365 goto out_netif_wake_queue; 1359 1366 if (err) 1360 1367 return err; 1361 - 1362 - total_frame_len += frame_len; 1363 1368 } 1364 1369 1365 1370 out_netif_wake_queue: ··· 1388 1397 return err; 1389 1398 1390 1399 tx_ring->tail += len; 1391 - netdev_completed_queue(priv->ndev, len, total_frame_len); 1392 1400 1393 1401 err = mcp251xfd_check_tef_tail(priv); 1394 1402 if (err) ··· 2433 2443 struct mcp251xfd_priv *priv = netdev_priv(ndev); 2434 2444 struct mcp251xfd_tx_ring *tx_ring = priv->tx; 2435 2445 struct mcp251xfd_tx_obj *tx_obj; 2436 - unsigned int frame_len; 2437 2446 u8 tx_head; 2438 2447 int err; 2439 2448 ··· 2451 2462 if (mcp251xfd_get_tx_free(tx_ring) == 0) 2452 2463 netif_stop_queue(ndev); 2453 2464 2454 - frame_len = can_skb_get_frame_len(skb); 2455 - can_put_echo_skb(skb, ndev, tx_head, frame_len); 2456 - netdev_sent_queue(priv->ndev, frame_len); 2465 + can_put_echo_skb(skb, ndev, tx_head, 0); 2457 2466 2458 2467 err = mcp251xfd_tx_obj_write(priv, tx_obj); 2459 2468 if (err)
+6 -2
include/linux/can/skb.h
··· 65 65 66 66 static inline void can_skb_set_owner(struct sk_buff *skb, struct sock *sk) 67 67 { 68 - if (sk) { 69 - sock_hold(sk); 68 + /* If the socket has already been closed by user space, the 69 + * refcount may already be 0 (and the socket will be freed 70 + * after the last TX skb has been freed). So only increase 71 + * socket refcount if the refcount is > 0. 72 + */ 73 + if (sk && refcount_inc_not_zero(&sk->sk_refcnt)) { 70 74 skb->destructor = sock_efree; 71 75 skb->sk = sk; 72 76 }