Commit f05fb508 authored by David S. Miller's avatar David S. Miller

Merge tag 'linux-can-fixes-for-5.16-20211106' of...

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

linux-can-fixes-for-5.16-20211106

Marc Kleine-Budde says:

====================
pull-request: can 2021-11-06

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

The first 3 patches are by Zhang Changzhong and fix 3 standard
conformance problems in the j1939 CAN stack.

The next patch is by Vincent Mailhol and fixes a memory leak in the
leak error path of the etas_es58x CAN driver.

Stephane Grosjean contributes 2 patches for the peak_usb driver to fix
the bus error handling and update the order of printed information
regarding firmware version and available updates.

The last 2 patches are by me and fixes a packet starvation problem in
the bus off case and the error handling in the mcp251xfd_chip_start()
function.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 70bf363d 69c55f6e
...@@ -1092,7 +1092,7 @@ static int mcp251xfd_chip_start(struct mcp251xfd_priv *priv) ...@@ -1092,7 +1092,7 @@ static int mcp251xfd_chip_start(struct mcp251xfd_priv *priv)
err = mcp251xfd_chip_rx_int_enable(priv); err = mcp251xfd_chip_rx_int_enable(priv);
if (err) if (err)
return err; goto out_chip_stop;
err = mcp251xfd_chip_ecc_init(priv); err = mcp251xfd_chip_ecc_init(priv);
if (err) if (err)
...@@ -2290,8 +2290,10 @@ static irqreturn_t mcp251xfd_irq(int irq, void *dev_id) ...@@ -2290,8 +2290,10 @@ static irqreturn_t mcp251xfd_irq(int irq, void *dev_id)
* check will fail, too. So leave IRQ handler * check will fail, too. So leave IRQ handler
* directly. * directly.
*/ */
if (priv->can.state == CAN_STATE_BUS_OFF) if (priv->can.state == CAN_STATE_BUS_OFF) {
can_rx_offload_threaded_irq_finish(&priv->offload);
return IRQ_HANDLED; return IRQ_HANDLED;
}
} }
handled = IRQ_HANDLED; handled = IRQ_HANDLED;
......
...@@ -664,7 +664,7 @@ int es58x_rx_err_msg(struct net_device *netdev, enum es58x_err error, ...@@ -664,7 +664,7 @@ int es58x_rx_err_msg(struct net_device *netdev, enum es58x_err error,
struct can_device_stats *can_stats = &can->can_stats; struct can_device_stats *can_stats = &can->can_stats;
struct can_frame *cf = NULL; struct can_frame *cf = NULL;
struct sk_buff *skb; struct sk_buff *skb;
int ret; int ret = 0;
if (!netif_running(netdev)) { if (!netif_running(netdev)) {
if (net_ratelimit()) if (net_ratelimit())
...@@ -823,8 +823,6 @@ int es58x_rx_err_msg(struct net_device *netdev, enum es58x_err error, ...@@ -823,8 +823,6 @@ int es58x_rx_err_msg(struct net_device *netdev, enum es58x_err error,
can->state = CAN_STATE_BUS_OFF; can->state = CAN_STATE_BUS_OFF;
can_bus_off(netdev); can_bus_off(netdev);
ret = can->do_set_mode(netdev, CAN_MODE_STOP); ret = can->do_set_mode(netdev, CAN_MODE_STOP);
if (ret)
return ret;
} }
break; break;
...@@ -881,7 +879,7 @@ int es58x_rx_err_msg(struct net_device *netdev, enum es58x_err error, ...@@ -881,7 +879,7 @@ int es58x_rx_err_msg(struct net_device *netdev, enum es58x_err error,
ES58X_EVENT_BUSOFF, timestamp); ES58X_EVENT_BUSOFF, timestamp);
} }
return 0; return ret;
} }
/** /**
......
...@@ -841,14 +841,14 @@ static int pcan_usb_start(struct peak_usb_device *dev) ...@@ -841,14 +841,14 @@ static int pcan_usb_start(struct peak_usb_device *dev)
pdev->bec.rxerr = 0; pdev->bec.rxerr = 0;
pdev->bec.txerr = 0; pdev->bec.txerr = 0;
/* be notified on error counter changes (if requested by user) */ /* always ask the device for BERR reporting, to be able to switch from
if (dev->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING) { * WARNING to PASSIVE state
err = pcan_usb_set_err_frame(dev, PCAN_USB_BERR_MASK); */
if (err) err = pcan_usb_set_err_frame(dev, PCAN_USB_BERR_MASK);
netdev_warn(dev->netdev, if (err)
"Asking for BERR reporting error %u\n", netdev_warn(dev->netdev,
err); "Asking for BERR reporting error %u\n",
} err);
/* if revision greater than 3, can put silent mode on/off */ /* if revision greater than 3, can put silent mode on/off */
if (dev->device_rev > 3) { if (dev->device_rev > 3) {
...@@ -883,6 +883,11 @@ static int pcan_usb_init(struct peak_usb_device *dev) ...@@ -883,6 +883,11 @@ static int pcan_usb_init(struct peak_usb_device *dev)
return err; return err;
} }
dev_info(dev->netdev->dev.parent,
"PEAK-System %s adapter hwrev %u serial %08X (%u channel)\n",
pcan_usb.name, dev->device_rev, serial_number,
pcan_usb.ctrl_count);
/* Since rev 4.1, PCAN-USB is able to make single-shot as well as /* Since rev 4.1, PCAN-USB is able to make single-shot as well as
* looped back frames. * looped back frames.
*/ */
...@@ -896,11 +901,6 @@ static int pcan_usb_init(struct peak_usb_device *dev) ...@@ -896,11 +901,6 @@ static int pcan_usb_init(struct peak_usb_device *dev)
"Firmware update available. Please contact support@peak-system.com\n"); "Firmware update available. Please contact support@peak-system.com\n");
} }
dev_info(dev->netdev->dev.parent,
"PEAK-System %s adapter hwrev %u serial %08X (%u channel)\n",
pcan_usb.name, dev->device_rev, serial_number,
pcan_usb.ctrl_count);
return 0; return 0;
} }
...@@ -986,7 +986,6 @@ const struct peak_usb_adapter pcan_usb = { ...@@ -986,7 +986,6 @@ const struct peak_usb_adapter pcan_usb = {
.device_id = PCAN_USB_PRODUCT_ID, .device_id = PCAN_USB_PRODUCT_ID,
.ctrl_count = 1, .ctrl_count = 1,
.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY | .ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY |
CAN_CTRLMODE_BERR_REPORTING |
CAN_CTRLMODE_CC_LEN8_DLC, CAN_CTRLMODE_CC_LEN8_DLC,
.clock = { .clock = {
.freq = PCAN_USB_CRYSTAL_HZ / 2, .freq = PCAN_USB_CRYSTAL_HZ / 2,
......
...@@ -75,6 +75,13 @@ static void j1939_can_recv(struct sk_buff *iskb, void *data) ...@@ -75,6 +75,13 @@ static void j1939_can_recv(struct sk_buff *iskb, void *data)
skcb->addr.pgn = (cf->can_id >> 8) & J1939_PGN_MAX; skcb->addr.pgn = (cf->can_id >> 8) & J1939_PGN_MAX;
/* set default message type */ /* set default message type */
skcb->addr.type = J1939_TP; skcb->addr.type = J1939_TP;
if (!j1939_address_is_valid(skcb->addr.sa)) {
netdev_err_once(priv->ndev, "%s: sa is broadcast address, ignoring!\n",
__func__);
goto done;
}
if (j1939_pgn_is_pdu1(skcb->addr.pgn)) { if (j1939_pgn_is_pdu1(skcb->addr.pgn)) {
/* Type 1: with destination address */ /* Type 1: with destination address */
skcb->addr.da = skcb->addr.pgn; skcb->addr.da = skcb->addr.pgn;
......
...@@ -2023,6 +2023,11 @@ static void j1939_tp_cmd_recv(struct j1939_priv *priv, struct sk_buff *skb) ...@@ -2023,6 +2023,11 @@ static void j1939_tp_cmd_recv(struct j1939_priv *priv, struct sk_buff *skb)
extd = J1939_ETP; extd = J1939_ETP;
fallthrough; fallthrough;
case J1939_TP_CMD_BAM: case J1939_TP_CMD_BAM:
if (cmd == J1939_TP_CMD_BAM && !j1939_cb_is_broadcast(skcb)) {
netdev_err_once(priv->ndev, "%s: BAM to unicast (%02x), ignoring!\n",
__func__, skcb->addr.sa);
return;
}
fallthrough; fallthrough;
case J1939_TP_CMD_RTS: case J1939_TP_CMD_RTS:
if (skcb->addr.type != extd) if (skcb->addr.type != extd)
...@@ -2085,6 +2090,12 @@ static void j1939_tp_cmd_recv(struct j1939_priv *priv, struct sk_buff *skb) ...@@ -2085,6 +2090,12 @@ static void j1939_tp_cmd_recv(struct j1939_priv *priv, struct sk_buff *skb)
break; break;
case J1939_ETP_CMD_ABORT: /* && J1939_TP_CMD_ABORT */ case J1939_ETP_CMD_ABORT: /* && J1939_TP_CMD_ABORT */
if (j1939_cb_is_broadcast(skcb)) {
netdev_err_once(priv->ndev, "%s: abort to broadcast (%02x), ignoring!\n",
__func__, skcb->addr.sa);
return;
}
if (j1939_tp_im_transmitter(skcb)) if (j1939_tp_im_transmitter(skcb))
j1939_xtp_rx_abort(priv, skb, true); j1939_xtp_rx_abort(priv, skb, true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment