Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6739369iob; Wed, 11 May 2022 04:28:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqBr8zxsD74cWwdNPebFq/+qeGj68oGiX7raRRzBH+dZlZlUqcum3vo1zM7sHV82X4DlBR X-Received: by 2002:a17:902:db05:b0:15e:d003:54f2 with SMTP id m5-20020a170902db0500b0015ed00354f2mr24588415plx.103.1652268503778; Wed, 11 May 2022 04:28:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652268503; cv=none; d=google.com; s=arc-20160816; b=xG++ZhDaERiC2dyxTER2du+gvoGkJFcYtUeMuTSQpO3wxhJnZYyJWv3z6+V9qdbv9f NbTqAAlN/0uaYTnh8T76lfnscJYbyChNnlAL+nrZCQ7TuysrqANsCDPgpqNTXkvB/BVh h8kaEg289OWvPjAadK2kS6ZVU0nzdoucREe8eRhQjMdSJiacYF2rJePdfcU6QwnWgZOJ spq7ApE8RgxrtPaZVrpGNthGbs+kCWjGXwXmG7x6TthTue4T78fa1AeEXg5DKs4lmXcq AMDG4tMrDW+TjKWXDjYlX2bSaBhFT81KxrngVnr73WOcMtM3qnfkm8WU6cy0DxFDQaVe QzTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:authorized-sender; bh=86PbT7rVtiBEgI+tJ7HmL3upgzSpi+6dlzTsEyVOJRg=; b=uLcgnCaEet1yPDDjXTpPv3RdIGMl7ysYDCNaey/aCzus2ODmhzYjAjHPhozUN+567k 8TQxf7Fyq93dbXWddZ/rNPYzk2C5A+1YNOjid9WYD6svfayLlVxPkt0DTWq3QOgNJu1j ZblKdO/4tdCL19As1/4yxhbaPhu83Witj1+4qn1rmPNVaQzKwHOH0POIPAnGNvOGmySU IPKDr5qBP8Tcek5L3NT3Cn+p9Awdfqq2kd5Vm1lSj31cNHIIcNMtI0ovUA5CLuyAm1Tv HqmiYMt4eeZP1quu4C8WCnuGBDm9S83SE51lqgpvwuY+UDUbMRrlQTDCRlaoR7FIXHsj CXNQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 19-20020a631953000000b003c25d640906si2542918pgz.97.2022.05.11.04.28.11; Wed, 11 May 2022 04:28:23 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240206AbiEKJfN (ORCPT + 99 others); Wed, 11 May 2022 05:35:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239742AbiEKJe7 (ORCPT ); Wed, 11 May 2022 05:34:59 -0400 Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88C72235151 for ; Wed, 11 May 2022 02:34:57 -0700 (PDT) X-Halon-ID: 9d93e752-d10d-11ec-9628-0050569116f7 Authorized-sender: andreas@gaisler.com Received: from andreas.got.gaisler.com (h-98-128-223-123.na.cust.bahnhof.se [98.128.223.123]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 9d93e752-d10d-11ec-9628-0050569116f7; Wed, 11 May 2022 11:34:55 +0200 (CEST) From: Andreas Larsson To: stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Marc Kleine-Budde Subject: [PATCH 4.19 2/2] can: grcan: only use the NAPI poll budget for RX Date: Wed, 11 May 2022 11:34:48 +0200 Message-Id: <20220511093448.14058-2-andreas@gaisler.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220511093448.14058-1-andreas@gaisler.com> References: <20220511093448.14058-1-andreas@gaisler.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 backport of commit 2873d4d52f7c52d60b316ba6c47bd7122b5a9861 upstream. The previous split budget between TX and RX made it return not using the entire budget but at the same time not having calling called napi_complete. This sometimes led to the poll to not be called, and at the same time having TX and RX interrupts disabled resulting in the driver getting stuck. Fixes: 6cec9b07fe6a ("can: grcan: Add device driver for GRCAN and GRHCAN cores") Link: https://lore.kernel.org/all/20220429084656.29788-4-andreas@gaisler.com Cc: stable@vger.kernel.org Signed-off-by: Andreas Larsson Signed-off-by: Marc Kleine-Budde --- drivers/net/can/grcan.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c index e126516ba648..c6a176d8681c 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -1141,7 +1141,7 @@ static int grcan_close(struct net_device *dev) return 0; } -static int grcan_transmit_catch_up(struct net_device *dev, int budget) +static void grcan_transmit_catch_up(struct net_device *dev) { struct grcan_priv *priv = netdev_priv(dev); unsigned long flags; @@ -1149,7 +1149,7 @@ static int grcan_transmit_catch_up(struct net_device *dev, int budget) spin_lock_irqsave(&priv->lock, flags); - work_done = catch_up_echo_skb(dev, budget, true); + work_done = catch_up_echo_skb(dev, -1, true); if (work_done) { if (!priv->resetting && !priv->closing && !(priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)) @@ -1163,8 +1163,6 @@ static int grcan_transmit_catch_up(struct net_device *dev, int budget) } spin_unlock_irqrestore(&priv->lock, flags); - - return work_done; } static int grcan_receive(struct net_device *dev, int budget) @@ -1246,19 +1244,13 @@ static int grcan_poll(struct napi_struct *napi, int budget) struct net_device *dev = priv->dev; struct grcan_registers __iomem *regs = priv->regs; unsigned long flags; - int tx_work_done, rx_work_done; - int rx_budget = budget / 2; - int tx_budget = budget - rx_budget; + int work_done; - /* Half of the budget for receiveing messages */ - rx_work_done = grcan_receive(dev, rx_budget); + work_done = grcan_receive(dev, budget); - /* Half of the budget for transmitting messages as that can trigger echo - * frames being received - */ - tx_work_done = grcan_transmit_catch_up(dev, tx_budget); + grcan_transmit_catch_up(dev); - if (rx_work_done < rx_budget && tx_work_done < tx_budget) { + if (work_done < budget) { napi_complete(napi); /* Guarantee no interference with a running reset that otherwise @@ -1275,7 +1267,7 @@ static int grcan_poll(struct napi_struct *napi, int budget) spin_unlock_irqrestore(&priv->lock, flags); } - return rx_work_done + tx_work_done; + return work_done; } /* Work tx bug by waiting while for the risky situation to clear. If that fails, -- 2.17.1