All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: "Stefan Mätje" <stefan.maetje@esd.eu>
Cc: Frank Jungclaus <frank.jungclaus@esd.eu>,
	Marc Kleine-Budde <mkl@pengutronix.de>,
	Vincent Mailhol <mailhol@kernel.org>,
	linux-can@vger.kernel.org, socketcan@esd.eu,
	"David S . Miller" <davem@davemloft.net>,
	Oliver Hartkopp <socketcan@hartkopp.net>,
	Simon Horman <horms@kernel.org>,
	Wolfgang Grandegger <wg@grandegger.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH v3 3/3] can: esd_usb: Add watermark handling for TX jobs
Date: Wed, 24 Sep 2025 17:27:20 -0700	[thread overview]
Message-ID: <20250924172720.028102e4@kernel.org> (raw)
In-Reply-To: <20250924173035.4148131-4-stefan.maetje@esd.eu>

On Wed, 24 Sep 2025 19:30:35 +0200 Stefan Mätje wrote:
> The driver tried to keep as much CAN frames as possible submitted to the
> USB device (ESD_USB_MAX_TX_URBS). This has led to occasional "No free
> context" error messages in high load situations like with
> "cangen -g 0 -p 10 canX".

I grepped for "No free context" :) perhaps use the old message from
before the previous patch, so that users who see those in the logs
can correlate with this patch better?

> Now call netif_stop_queue() already if the number of active jobs
> reaches ESD_USB_TX_URBS_HI_WM which is < ESD_USB_MAX_TX_URBS. The
> netif_start_queue() is called in esd_usb_tx_done_msg() only if the
> number of active jobs is <= ESD_USB_TX_URBS_LO_WM.
> 
> This change eliminates the occasional error messages and significantly
> reduces the number of calls to netif_start_queue() and
> netif_stop_queue().
> 
> The watermark limits have been chosen with the CAN-USB/Micro in mind to
> not to compromise its TX throughput. This device is running on USB 1.1
> only with its 1ms USB polling cycle where a ESD_USB_TX_URBS_LO_WM
> value below 9 decreases the TX throughput.

> -	netif_wake_queue(netdev);
> +	if (atomic_read(&priv->active_tx_jobs) <= ESD_USB_TX_URBS_LO_WM)
> +		netif_wake_queue(netdev);
>  }

> -	/* Slow down tx path */
> -	if (atomic_read(&priv->active_tx_jobs) >= ESD_USB_MAX_TX_URBS)
> +	/* Slow down TX path */
> +	if (atomic_read(&priv->active_tx_jobs) >= ESD_USB_TX_URBS_HI_WM)
>  		netif_stop_queue(netdev);
>  
>  	err = usb_submit_urb(urb, GFP_ATOMIC);

I don't know much about USB. Is there some locking that makes this not
racy? I recommend using the macros from net/netdev_queues.h like
netif_txq_maybe_stop() the re-checking on one side is key.

  reply	other threads:[~2025-09-25  0:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-24 17:30 [PATCH v3 0/3] can: esd_usb: Fixes Stefan Mätje
2025-09-24 17:30 ` [PATCH v3 1/3] can: esd_usb: Fix not detecting version reply in probe routine Stefan Mätje
2025-09-24 17:30 ` [PATCH v3 2/3] can: esd_usb: Fix handling of TX context objects Stefan Mätje
2025-09-24 17:30 ` [PATCH v3 3/3] can: esd_usb: Add watermark handling for TX jobs Stefan Mätje
2025-09-25  0:27   ` Jakub Kicinski [this message]
2025-09-26  1:35     ` Stefan Mätje
2025-09-26 19:50       ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250924172720.028102e4@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=frank.jungclaus@esd.eu \
    --cc=horms@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=mailhol@kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=socketcan@esd.eu \
    --cc=socketcan@hartkopp.net \
    --cc=stefan.maetje@esd.eu \
    --cc=wg@grandegger.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.