From patchwork Mon Oct 24 11:26:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10170 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp640628wru; Mon, 24 Oct 2022 13:33:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4SihnaxSFDXx+fGVyeg+VWoiVV802AVEo6wi/7Esw+vY15AdoHEpXiOC2NuiR/RIADGDkH X-Received: by 2002:a63:2d8:0:b0:46e:9da4:df67 with SMTP id 207-20020a6302d8000000b0046e9da4df67mr20255780pgc.176.1666643585245; Mon, 24 Oct 2022 13:33:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666643585; cv=none; d=google.com; s=arc-20160816; b=FwrQGNyuYphW9luj0cUKq9wBiRSrdQSI53u9IaJTYvJmNB/seGdG+2Ap4FDrNzW+FV vyNh6RwicbtdII/ud4aq/5gQd33hgZRT1Nd9aSrNCV0/SauUvbel8aWLhEv5z9C8j5Gj isBasN8cDaa/a9H9JLi57WikVcow/fonNSnJjHRkD5fELAXaoUQct/wOLi4zQ7+gnIgd svBhB0Kll4PFLAZrk2U46d8BCq3aLWkSl/RHF1HrmCYTjRP3QaEbt9Kh2RWLUQA3/pbo JbDf7HuRUtWoJB84JE4GWhUEN8nVWNr9IskfHiL0JVBt7/0OIDyJyrddbJhnwIzP6LOK w3uA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s3-20020a63dc03000000b0046ef67cc137si448696pgg.522.2022.10.24.13.32.51; Mon, 24 Oct 2022 13:33:05 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747602464154469367?= X-GMAIL-MSGID: =?utf-8?q?1747602464154469367?= 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;