From patchwork Wed Oct 19 08:22:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4567 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp204850wrs; Wed, 19 Oct 2022 01:47:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5WV0o8It2vdK3r7YikbMs9EwsusXIiUVmMj53DzVM/LXeCwrALnBHrTnaWdI9EtBx5TpLF X-Received: by 2002:a17:90b:3850:b0:20d:54f2:a780 with SMTP id nl16-20020a17090b385000b0020d54f2a780mr44041589pjb.115.1666169188665; Wed, 19 Oct 2022 01:46:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666169188; cv=none; d=google.com; s=arc-20160816; b=hSdWy6WHU5pyiOtUeTzIpGIqcB6JAo9XeOP4sox5zCg/82w56oAOLXieCvOVdRdmg4 RnRQLUBrNHW3vRkZxrmoYcX5c8dtlY/FlyynQxOYmZ7mSpUW1a8yQNlz4Iz5wMuuv8sm PosZ2ApPoB7wRTgNgtrJgvAfe0RSHk3jIlhjOIsOSSHkdFw316X11DjQEvqi0eCbuJHp pSM+116NmOXrxXbHRD0ktGN3moWIkotKMuscTG6r75M04asKZinJSCGfmjinMprSMXU4 KP/m0M9Zq9o4AjVTXBLLRfJxFyijNG8pVgnEGVKHkRm+b9cwKrzYUbPi3M03KXJwDZEM o5fQ== 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=V5gcis1ss8NXQ58CIc+kGQNew0GC3iCRBxpmUYUIvlU=; b=WW9/RW5qkzBFCwlLXHU+kAmyy31YpOq95D6j2BYtiYCl/Hkiin0uo0L6tGSsm+J5p9 Vi+o0boSo15NLIJYsiOVHdfuZ0c4RWWH6T/XlcBnL4Qhwv020AV+2q9Y33TcNN87PURL nG9tXaXLovIrPyezI5MGIdLC376YkusSxzYz3vWfNzSlNftlwU1CY1QQGf8Oe8gtYBh2 cMyevHrG2sYNJtcZyYekH9IUa+QC11BfmEM+52tBgTM+bYE9YRcti5Z0vDcfX1adoMPG drNHfPUarev2UIasTPiOEoMdDBDZP6n0kCVnp5Ai8dmCQu2Wo4o81DPHeMaINwX38zdv ONGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=O8Ousj+F; 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 y9-20020a655b09000000b004635d57777bsi18007683pgq.748.2022.10.19.01.46.15; Wed, 19 Oct 2022 01:46:28 -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=O8Ousj+F; 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 S231343AbiJSIps (ORCPT + 99 others); Wed, 19 Oct 2022 04:45:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231449AbiJSIoL (ORCPT ); Wed, 19 Oct 2022 04:44:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFAFD89963; Wed, 19 Oct 2022 01:42:47 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 218B9617D1; Wed, 19 Oct 2022 08:40:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2EA44C433D6; Wed, 19 Oct 2022 08:40:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666168844; bh=O5hT/gQYm6/LEbKSOMr4FejGgecjPZtk9ndOZq8vVHM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O8Ousj+FGM/GJehWCEF6xT6gDQ6tBG3Jy4FeuHYsQjv/kLYj7thFnDACw9xX01pNk CuAo2EKpqj3K5MXMI2xI0wQ0SviEcwIVMdGXSHsZrTrg/hMkpUuF/xr4/Gl6maWAa9 2h4diY5Gp+Fmg8uJT66VS9qb0n7d3uqKx+jge4AA= 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 6.0 035/862] can: kvaser_usb_leaf: Fix TX queue out of sync after restart Date: Wed, 19 Oct 2022 10:22:02 +0200 Message-Id: <20221019083251.563976478@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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?1747105022909661286?= X-GMAIL-MSGID: =?utf-8?q?1747105022909661286?= 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 @@ -477,7 +477,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 @@ -1426,6 +1426,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;