In rare cases of very high bus load, the firmware of the PEAK-System PCAN-USB Pro FD HW v4 can generate messages warning that the receive cache capacity is about to be exceeded. This modification prevents the driver from flooding the kernel log with messages and memory dumps that are far too verbose in such cases, by limiting their production to once for all. Signed-off-by: Stephane Grosjean <s.grosjean@xxxxxxxxxxxxxxx> --- drivers/net/can/usb/peak_usb/pcan_usb_fd.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c index a1c339716776..aa0b68c1ae81 100644 --- a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c +++ b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c @@ -667,6 +667,19 @@ static int pcan_usb_fd_decode_error(struct pcan_usb_fd_if *usb_if, return 0; } +/* Handle uCAN Rx cache warning messages. + * + * Such messages SHOULD NOT occur. If they do, then this might come from + * massive PING host flooding that prevents PCAN-USB Pro FD HW v4 to handle + * CAN traffic anymore. + */ +static void pcan_usb_fd_handle_rx_cache_warn(struct peak_usb_device *dev, + struct pucan_msg *rx_msg) +{ + netdev_warn_once(dev->netdev, + "Rx cache size warning! Possible loss of frames\n"); +} + /* handle uCAN overrun message */ static int pcan_usb_fd_decode_overrun(struct pcan_usb_fd_if *usb_if, struct pucan_msg *rx_msg) @@ -768,6 +781,14 @@ static int pcan_usb_fd_decode_buf(struct peak_usb_device *dev, struct urb *urb) goto fail; break; + case PUCAN_MSG_CACHE_CRITICAL: + pcan_usb_fd_handle_rx_cache_warn(dev, rx_msg); + + /* Rx cache warning means possible overrun cases in + * the device. + */ + fallthrough; + case PCAN_UFD_MSG_OVERRUN: err = pcan_usb_fd_decode_overrun(usb_if, rx_msg); if (err < 0) -- 2.34.1