Re: [PATCH v2] can: peak_usb: fix potential kernel log flooding

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri. 16 Feb. 2024, 22:57, Stephane Grosjean
<s.grosjean@xxxxxxxxxxxxxxx> wrote:
>
> 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)
                                                                 ^^^^^^

That rx_msg parameter is unused.

Do you think it is worth keeping that
pcan_usb_fd_handle_rx_cache_warn() function? Wouldn't it be easier to
directly call netdev_warn_once() from pcan_usb_fd_decode_buf()?

> +{
> +       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




[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux