Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7382880rwi; Mon, 24 Oct 2022 13:53:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM44y29AXUO1TaCKjc1tEkMscql0YLxJC3YPnc3D2S3RY3NLvF4Q3fW2fh4f8+dY2zuVpTdD X-Received: by 2002:a65:6856:0:b0:46e:bcc2:8b36 with SMTP id q22-20020a656856000000b0046ebcc28b36mr15689712pgt.378.1666644833520; Mon, 24 Oct 2022 13:53:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666644833; cv=none; d=google.com; s=arc-20160816; b=T5UuBasmMUap1bwrYbhCsysFXXeYw/FU5CT0ljXRdbli9/j56mECp+7bx3KgM5+h2v 6IN6RP2htxe4t3h2HuGbV2qdnEZ2DdSXI3mJs1mHbOBQej4PHmD40/FazHfIap5PF7lI RHnkFa2x/ON9n2UH17JwOHSFMZs7qgFzOzgfDoUme016ciW6CaFGueSOU14kY8qkpsqm twayBB0T7cRFxr9WBm+mnZpgpCwECjm11xl+lWB9ndzLPo/5aPUayucClZi1wuYHGrcR l4mF8kF3fDUI6sLiNrdXDBuONr7firYV4EJ57A5WAVFbLqAMCq8GXkPPxi99vB2iLNRv XuyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FItYcj3d90E13OAXhbQyW+ZGqKFJfAayNRBymu5q/74=; b=ABFihHz9HxqkSEDzcY6bF8m8RQz3E4E8RnQEEyzAZInkRyrC9KkI6QgXUbOeX/axci 8UNdYq+MDT2xNOwVqDO2jrZjZAaZrS0rymb2Dgkep2HMVoiHcS2BT9mcF3nJSSKdNbdj 8CS4V7kKJaJ+gsl9mt7ftNmFKfVwSArF+O2WDOSB1037ojGb8/vSCShj+fXxVMxqb1Ap UICnDltUsNHafE+Qaq7Vjj0TLSm4D4sOE3Zl+EFaWCRHfYRTytZz4FR8gNNYVeTUlAyK +rerkw6Qa3SeNLOW7eoeM9FLJ+fX/sFZpUnPLr61fskvNwECGQbkQVysDHK1RpWIrlX7 TNiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MeWtdNEa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s15-20020a056a00194f00b00562db93e317si719080pfk.114.2022.10.24.13.53.41; Mon, 24 Oct 2022 13:53:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MeWtdNEa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234228AbiJXUWt (ORCPT + 99 others); Mon, 24 Oct 2022 16:22:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234149AbiJXUV7 (ORCPT ); Mon, 24 Oct 2022 16:21:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 205AE19DD80; Mon, 24 Oct 2022 11:38:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 38269B815B8; Mon, 24 Oct 2022 12:18:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E291C433D7; Mon, 24 Oct 2022 12:18:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613881; bh=547xsTNwHNS98HazWD5C1d4zRtBg8qNe5JpQzIaOh8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MeWtdNEakBBVLoBvbCcEMvp9crjGRCAyxvJtpohK8nQgVKOLeOB/89R6QQ3bbrZXC Flf/VlTmMHlVflP/d0Zfew8Z+hjEuLZVyGGmSP+f2wPxGXNWvQpoJrtvOSKZpkH2hC hkTGAoEVOkgT937wfWp4arQLdr4Q4G9lIDx6Sp0c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jimmy Assarsson , Anssi Hannula , Marc Kleine-Budde Subject: [PATCH 5.10 020/390] can: kvaser_usb_leaf: Fix TX queue out of sync after restart Date: Mon, 24 Oct 2022 13:26:57 +0200 Message-Id: <20221024113023.409427251@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anssi Hannula commit 455561fb618fde40558776b5b8435f9420f335db upstream. The TX queue seems to be implicitly flushed by the hardware during bus-off or bus-off recovery, but the driver does not reset the TX bookkeeping. Despite not resetting TX bookkeeping the driver still re-enables TX queue unconditionally, leading to "cannot find free context" / NETDEV_TX_BUSY errors if the TX queue was full at bus-off time. Fix that by resetting TX bookkeeping on CAN restart. Tested with 0bfd:0124 Kvaser Mini PCI Express 2xHS FW 4.18.778. Cc: stable@vger.kernel.org Fixes: 080f40a6fa28 ("can: kvaser_usb: Add support for Kvaser CAN/USB devices") Tested-by: Jimmy Assarsson Signed-off-by: Anssi Hannula Signed-off-by: Jimmy Assarsson Link: https://lore.kernel.org/all/20221010150829.199676-4-extja@kvaser.com Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman --- drivers/net/can/usb/kvaser_usb/kvaser_usb.h | 2 ++ drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c | 2 +- drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb.h +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb.h @@ -178,6 +178,8 @@ struct kvaser_usb_dev_cfg { extern const struct kvaser_usb_dev_ops kvaser_usb_hydra_dev_ops; extern const struct kvaser_usb_dev_ops kvaser_usb_leaf_dev_ops; +void kvaser_usb_unlink_tx_urbs(struct kvaser_usb_net_priv *priv); + int kvaser_usb_recv_cmd(const struct kvaser_usb *dev, void *cmd, int len, int *actual_len); --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c @@ -453,7 +453,7 @@ static void kvaser_usb_reset_tx_urb_cont /* This method might sleep. Do not call it in the atomic context * of URB completions. */ -static void kvaser_usb_unlink_tx_urbs(struct kvaser_usb_net_priv *priv) +void kvaser_usb_unlink_tx_urbs(struct kvaser_usb_net_priv *priv) { usb_kill_anchored_urbs(&priv->tx_submitted); kvaser_usb_reset_tx_urb_contexts(priv); --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c @@ -1430,6 +1430,8 @@ static int kvaser_usb_leaf_set_mode(stru switch (mode) { case CAN_MODE_START: + kvaser_usb_unlink_tx_urbs(priv); + err = kvaser_usb_leaf_simple_cmd_async(priv, CMD_START_CHIP); if (err) return err;