From patchwork Sat Oct 22 07:18:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7334 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1094745wrr; Sat, 22 Oct 2022 01:00:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5iMSi6WGOveS9CapQv8MLwWyCCGcXAB7QKLW24R4hkk02HaC2mTlCMDuE1c3RPEuWAVDYc X-Received: by 2002:a65:6bd3:0:b0:42b:9117:b9d1 with SMTP id e19-20020a656bd3000000b0042b9117b9d1mr19412493pgw.238.1666425655280; Sat, 22 Oct 2022 01:00:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666425655; cv=none; d=google.com; s=arc-20160816; b=N1PmXKrimfLdnt8LACN/u1yc1ceYWbCIDRzGxgeMwJQw1W+CI5XsvM75ME5BFPpfty 9Sfyo0xuqWsgxRcyCvS60yJOVeyuMZDj1dZDevVr9sE2Ka65s0TaBSN16fR9TEem+srV P0njzNW0RlH145Y+equu3Ps/TqzK5wgG1C73QobE+nOTHEVAOtWu+N1aszAEgEe52exG OQakGMwr+iuizMG8mbZ4IywFDZiJZ1LA1VlpU07I9zwC++AjcZOqwhyJZr1w8K0Umgbo AF46pxSFBIWSyr04WzyYgwnTHrlnobhj2g6vA7ghpBI8+Cwb7fywV6yrql+TB7N2AYEE lAuw== 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=ICOHt6j6YbzkVBn2kxni7Ikzi3RJzqPvyzW1AkzdPgM=; b=QvpgdkdoC6CV7sEisJeuhqBKEh0gYp+beLCJ+NPpwVYrAqUmACUaKADp4dOB+qrTRf 0srOBxXaSfGSC0hkO5LizyjGrD1RyIOnBu0BazPYrZkP5kjAurzDk4BDe8+thJTWGzfB i53hhhWzw2Oj7ZcTYWkjDZeC/UQmQWvFVRHP0L1/okYKodbGZ7Yph/ebXsVWvrV3sGGd cOc2Q53uf7NeEozOpKcyV6UoH/RqRzzZ1jxOMo6UxCgnGsQJI0vHWyI0rJHLn5JoBR3g fGOPzhgETRvFUj/LvM21tjXPBlX1/jtG/NVs1IKMGh9yRRCLtWEbhYKudDwkBmD5R67U PLZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HBuJTBqv; 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 q17-20020a656251000000b0044c3ec9ea71si25970825pgv.630.2022.10.22.01.00.38; Sat, 22 Oct 2022 01:00:55 -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=HBuJTBqv; 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 S232404AbiJVH6x (ORCPT + 99 others); Sat, 22 Oct 2022 03:58:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232108AbiJVHyE (ORCPT ); Sat, 22 Oct 2022 03:54:04 -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 9E4B066F29; Sat, 22 Oct 2022 00:47:10 -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 0412AB82DEF; Sat, 22 Oct 2022 07:37:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66246C433C1; Sat, 22 Oct 2022 07:37:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424231; bh=u9d3oKohvpH9ZPwexg1uXySnrW6COWM2acNwiTVHdCE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HBuJTBqvQzqebnEZ5wPZ3wVawQRmKHuXfCae8akOWDwfRTdBgBliTm2LpVrG7YVr3 /JWenuZurHOBca+3Insxt323i5QyyR0gtQJOlCFhabXQtRRc7XwQxCrkiFccFZCjby stW/Nw9pfLzPVYNEiveA/ZIZpMVO8hUAL0I+1EJk= 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.19 030/717] can: kvaser_usb_leaf: Fix TX queue out of sync after restart Date: Sat, 22 Oct 2022 09:18:29 +0200 Message-Id: <20221022072420.440551038@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747373947746550282?= X-GMAIL-MSGID: =?utf-8?q?1747373947746550282?= 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 @@ -177,6 +177,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 @@ -476,7 +476,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 @@ -1425,6 +1425,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;