Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1004623iob; Fri, 13 May 2022 19:19:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKBRCDbV8sdIngvLg3eHgEeKndngtUFi0RqG+2ZJ97yoS6JBHkVh2AoCfF5dsZNUnHIdB8 X-Received: by 2002:a05:600c:154d:b0:394:8d64:9166 with SMTP id f13-20020a05600c154d00b003948d649166mr7015420wmg.102.1652494787954; Fri, 13 May 2022 19:19:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652494787; cv=none; d=google.com; s=arc-20160816; b=W1SKSVrSFAjKTYQ6iPhcYoySf2cq4LnFfi9fNuw6Z3CeJAJ92wkUMEGdB3d7PCrDff KFgIy2tZdoFax0+8n8w1TnskT/exFpciQodH5ZAzpB6KffdL+SJlDQuuYHeRKM5rnzm0 PXvdgZulqYoaTZ0FUQvJhY5SDske+Q+cQ6V0eXnPUNXLhtBcEGXnHRe8e69ZX6k0SD/b JtenyLAEd09Tz8E2mBW319nkSsAqmTRfexoTD1E5kfw62CQB/GbqC+3KBxT8yMNGZB1b TNQkeYxJR828n2XuC26APM+uhX9THM/1RTcx+jQRc4JwvQMbITiYfD9KY38Ej1dRiBIn m7hg== 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=ZdcFuOJyWvXaB4hxfYz5eMAzGI5KYw0HCxB3cGeaUlI=; b=NNqvQAcJRV++jz5hHbWCLiIWxcDb9ksY15UXUg57mxxurgusAZJA54oSWU/tF7QgM9 XtKHKp2Rax1xhohhqtADMCOUZJet4+4CathNClU1vwBZ7nmq7BerjoBUviQ/LEBZtBOH GbQFc6bEasqSieP56DK8iL9ANwPpiRlet/7nk/azxDCGsJFT1vEGy//Cl+Sil2FJMYwb awVR2JkUuM5GQTKR4lug5zvPuFQd+cvmQ0ROOhlYS3KwaMcbsWEi5a5vt2Ml5bQYWo4M ej3mi5KOWDq/YxNIHW8kkXSLyHuAxZw1xLIjfrDLKBxL0mDyGBVjl2fN135r1o+BCS4t pkhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=e6iB7bEk; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 9-20020a056000154900b0020ce5ab1ce0si5222983wry.19.2022.05.13.19.19.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 19:19:47 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=e6iB7bEk; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 709E04B5F7D; Fri, 13 May 2022 17:36:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357191AbiEMOYr (ORCPT + 99 others); Fri, 13 May 2022 10:24:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358971AbiEMOYm (ORCPT ); Fri, 13 May 2022 10:24:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EE995E168; Fri, 13 May 2022 07:24:34 -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 7CA4D62153; Fri, 13 May 2022 14:24:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E621C34100; Fri, 13 May 2022 14:24:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652451872; bh=QF88le2UwZdYFdKhakOikXNGtWetoJ79BBE9pUZFl9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e6iB7bEktaQM5DqEAPMQ3Ex63pBzsKL5IDrHLYwj32tJU1MlW1RTdIZCNkpGbZm74 GtRBEYOm31C5wdQxAAky+tOFYF4tlHCf4SmCtqJzXP3QdJCekXkwvWdOHEHuYL5LAR r1K2RqWt32UePPcGl/JH3j9hN6WU+WzBpxRC/pY8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andreas Larsson , Marc Kleine-Budde Subject: [PATCH 4.9 4/7] can: grcan: only use the NAPI poll budget for RX Date: Fri, 13 May 2022 16:23:19 +0200 Message-Id: <20220513142226.041910821@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220513142225.909697091@linuxfoundation.org> References: <20220513142225.909697091@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 From: Andreas Larsson 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 Signed-off-by: Greg Kroah-Hartman --- drivers/net/can/grcan.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -1141,7 +1141,7 @@ static int grcan_close(struct net_device 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(struc 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(struc } 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 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 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,