Skip to content

Commit 516a0cd

Browse files
can: gs_usb: gs_usb_xmit_callback(): fix handling of failed transmitted URBs
The driver lacks the cleanup of failed transfers of URBs. This reduces the number of available URBs per error by 1. This leads to reduced performance and ultimately to a complete stop of the transmission. If the sending of a bulk URB fails do proper cleanup: - increase netdev stats - mark the echo_sbk as free - free the driver's context and do accounting - wake the send queue Closes: candle-usb/candleLight_fw#187 Fixes: d08e973 ("can: gs_usb: Added support for the GS_USB CAN devices") Link: https://patch.msgid.link/20251114-gs_usb-fix-usb-callbacks-v1-1-a29b42eacada@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
1 parent 30db445 commit 516a0cd

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

drivers/net/can/usb/gs_usb.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,8 +750,21 @@ static void gs_usb_xmit_callback(struct urb *urb)
750750
struct gs_can *dev = txc->dev;
751751
struct net_device *netdev = dev->netdev;
752752

753-
if (urb->status)
754-
netdev_info(netdev, "usb xmit fail %u\n", txc->echo_id);
753+
if (!urb->status)
754+
return;
755+
756+
if (urb->status != -ESHUTDOWN && net_ratelimit())
757+
netdev_info(netdev, "failed to xmit URB %u: %pe\n",
758+
txc->echo_id, ERR_PTR(urb->status));
759+
760+
netdev->stats.tx_dropped++;
761+
netdev->stats.tx_errors++;
762+
763+
can_free_echo_skb(netdev, txc->echo_id, NULL);
764+
gs_free_tx_context(txc);
765+
atomic_dec(&dev->active_tx_urbs);
766+
767+
netif_wake_queue(netdev);
755768
}
756769

757770
static netdev_tx_t gs_can_start_xmit(struct sk_buff *skb,

0 commit comments

Comments
 (0)