From patchwork Mon Oct 24 11:28:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8979 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp438603wru; Mon, 24 Oct 2022 06:01:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7GukSBfQrz6Kxj3bG+lOVYxVNH3ASaFo6u/CL+AMA0uMdGwlZlFSwF0FpzN4B/n8zOflJ4 X-Received: by 2002:a17:903:41c7:b0:182:a32f:4db5 with SMTP id u7-20020a17090341c700b00182a32f4db5mr33377840ple.22.1666616494334; Mon, 24 Oct 2022 06:01:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666616494; cv=none; d=google.com; s=arc-20160816; b=ghlCvPhz/HzRrb/p6ARjlq20WV4dMZPcvoPXgU3kriN7bPJ58/Khrruje0kQtzDq5Z 56ZbkaseaCx/BKc4O3L36sYSZQeE1lKpjSx9Xi3Bp3mlOnm/oZp3dPrVmZA1YnHP9jho KEDeoVohknVFgdt1m2xgTmAr89QHx1Q5t0tDIn4rjzCaj6c+Yc3hj7jCWcl+trbe7DbS eKocMN1bB+O8a9XQ0stLWdsx+MdORPImzRv974GHD9RwJG1SDWJIy6jtIunSYOVyKide Cup3QMf9MN5D59jVDAECYWqzJ2WjcZT4TIT4oYsye/1PE79MRGwZWsQQGDoveOWnWRch PzbA== 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=DoE7UcvTpmOMeQGR+ZmgxF9pRPh2p8UZftQLIWDfTTOQHqYt1oGpurjxZ+ZCEekdbG J+6pDm59bFJ9GGoAVFe0T+2VGHzz9ZF/XdXTrThETAMlaG/tiDNjN5z2ehf85d3VhtGw nwp/CiREWK3Mby9DcK5Zer3W9/guKAaxceFPZpYV08En/+5KhVH+THUN+S/0UNg7lahE YwxEQpUx7x43yVBfdsv+c4HoehpyftHPaLnLvpGeYVQ9hb/FYtQQBBilbUJ5L8tiLqKh cFHAG34LELkkalQWOxYFaZu9CJGRSEMJ0UpDqCveGgW+Hw2lZ28yDNPIeyX6BVfuyiFe B3aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tcvF8UQB; 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 u200-20020a6279d1000000b0056b8ae6149csi7549544pfc.244.2022.10.24.06.01.01; Mon, 24 Oct 2022 06:01:34 -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=tcvF8UQB; 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 S234928AbiJXNAn (ORCPT + 99 others); Mon, 24 Oct 2022 09:00:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234771AbiJXM6i (ORCPT ); Mon, 24 Oct 2022 08:58:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B898181116; Mon, 24 Oct 2022 05:17:41 -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 06942612CD; Mon, 24 Oct 2022 12:05:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 194BDC433C1; Mon, 24 Oct 2022 12:05:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613124; bh=547xsTNwHNS98HazWD5C1d4zRtBg8qNe5JpQzIaOh8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tcvF8UQBw9xmkOsPUSQ9iJCC0O/Y/lSy5GemcCnd0mpCyh2o3REevqq2ljjZk+ydf G/9Xdylk1dgwim2f0y57tMfuGiW2ZTK9zRtP/OuCzgNhosn0gRyMzgu1jKbTU3w+uc ZJhpcSg+c1gVQFNehx3yhQzrJ4dayC3amWIxn/FU= 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.4 018/255] can: kvaser_usb_leaf: Fix TX queue out of sync after restart Date: Mon, 24 Oct 2022 13:28:48 +0200 Message-Id: <20221024113003.031211772@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@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?1747574057109046156?= X-GMAIL-MSGID: =?utf-8?q?1747574057109046156?= 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;