Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp1283197pxt; Sat, 7 Aug 2021 06:10:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDEOmB7/UMKrjGrckSmFmvuV1y1sGBcdyTtbjR0WWN4wtN8CXt8eJeN3yEKRrs84/sYc8q X-Received: by 2002:a05:6602:3345:: with SMTP id c5mr278577ioz.73.1628341808665; Sat, 07 Aug 2021 06:10:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628341808; cv=none; d=google.com; s=arc-20160816; b=fH9QV7hQlKq+Hfv1Z0YAfagZrmWSWRD12G+W63NSAHFvQFfw6kdxnoyP9POThr7nS5 Y49HlRnlIiEnb00iZjyTKM1uiIok/uzgXvDMMKQNw5SKLEppTYCJNYkQ7cdIGzACJn6n M+hkUVsRTnCmSAsrox4mtUWAMxK8Bv25IMD0CQTUKp9Ysd18KjeoUWmPYdXEjoK6gIZu ZBqjHCK8UlmPhlUJXpcHNOgdC33FqX+S41cfQ+SnKDFdmz77eNPy/F0BgrpAv3EekHvP FIxGVS2k2Zx1dTfYofnkYTZXc+07mp6e4bNNviidJtp09xJo4hcl3Oh4Dd0wF5dP7TFL CTIQ== 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:dkim-signature; bh=qcQQKkpQcTduRVA/CnmRQITGUWlSeT/brnZTnXQ+50c=; b=qSsUQrRC6yWi9PJrCMhEU/RmIt7LnGaheW5eUEm20/WXp7BjuARt/0GbzOWkgtdpM6 VmGM2mav/fwlE/xis4twyj+23ocac0+bD05n5geNmt+QfEGQXzRd+a8zQ+sKxAP1Z/kT BCiXBTqUEGXMLgiU48CyKi1CjcPp+38WgB7SQjvsy4mI2q7t0ui1JsQ5XldOpervIrjV VVgIidY7pqt2P7SLbIfvk9sPm+vXGX9x8h+Sp3fa0RpO6kfOOYuybYjMze5KcUNPYMip tBBLRSBIDAc+pa4DXMrncc7A5B+xim8Eu93mwB+7MhK/3wg6Nrn3S57lKky32VmYgQ5U 1R+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@libero.it header.s=s2021 header.b=gNXMP5g8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=libero.it Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o19si11060833jav.61.2021.08.07.06.09.57; Sat, 07 Aug 2021 06:10:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@libero.it header.s=s2021 header.b=gNXMP5g8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=libero.it Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232324AbhHGNJ0 (ORCPT + 99 others); Sat, 7 Aug 2021 09:09:26 -0400 Received: from smtp-32.italiaonline.it ([213.209.10.32]:57646 "EHLO libero.it" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231950AbhHGNJZ (ORCPT ); Sat, 7 Aug 2021 09:09:25 -0400 Received: from passgat-Modern-14-A10M.homenet.telecomitalia.it ([82.60.87.158]) by smtp-32.iol.local with ESMTPA id CM3WmQm3XPvRTCM3cmIfZ4; Sat, 07 Aug 2021 15:08:08 +0200 x-libjamoibt: 1601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=libero.it; s=s2021; t=1628341688; bh=qcQQKkpQcTduRVA/CnmRQITGUWlSeT/brnZTnXQ+50c=; h=From; b=gNXMP5g8mcUSeTr+UsiRu0FcPlG8lvMhLc0HivVzUtgdjJnMjCu4FdIHqXnSoXjEO /9RPyLU6Pkcpcl8HVre90o9A3yDkjxGYqOdby9OClniPRYvJj2zgFGBi7kHFHgY4SB LTeoRuCdpeNJwsth9cKDAc9JITooyUOoB/huDjK9PRuuRpz2mpfaSz4Iu4Gfo4fKyE RmqMFY0Oy7i+Tc39BmJcBGOCjdEWc1SeKZdFuDKG1782SrW2M0JwQo2NFYFFlzAJOP sTnZXyE07cfEBM16eSkNAs9spuxTB+CMGMDjIM+3o1kV1oySKbb7ZYTCatB+g6wAt+ 9UcRdy6U70uvw== X-CNFS-Analysis: v=2.4 cv=NqgUz+RJ c=1 sm=1 tr=0 ts=610e85b8 cx=a_exe a=Hc/BMeSBGyun2kpB8NmEvQ==:117 a=Hc/BMeSBGyun2kpB8NmEvQ==:17 a=0RFnQWo-as75lT-uasUA:9 From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Gianluca Falavigna , Dario Binacchi , "David S. Miller" , Jakub Kicinski , Marc Kleine-Budde , Oliver Hartkopp , Vincent Mailhol , Wolfgang Grandegger , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v3 2/4] can: c_can: exit c_can_do_tx() early if no frames have been sent Date: Sat, 7 Aug 2021 15:07:58 +0200 Message-Id: <20210807130800.5246-3-dariobin@libero.it> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210807130800.5246-1-dariobin@libero.it> References: <20210807130800.5246-1-dariobin@libero.it> X-CMAE-Envelope: MS4xfFXjyjkSSREEemsSXHD6ghKK6Ear5v3Gm1j9QSAtbp+ZLi0S+dxRbwa1ixcbKnNpPW9G15s+HZxGOUSaQCbbhZ2TQURMi8QBGm6Z54yoHyPdL3QXcVNP BMiNJz8LTXzQtOjmHx2DGyNucM60bl0VQXUxG+aANmgHbpd+u8SoVLDRdxIRLejPEEAuQ6Dvesb6kPHJXQ1G62S0+DikujHvIa9JIBJp/au1CHnHj0GaTiYk u3awC2snpN5WVznLBOIl2MtJsoXQTlWmSO21ILaZAZIG5STGS9UynV5JU2q36XwSkwxDzksuO5lljJSLcZMaKaZbpGCMivkE53WDJv6aWD3LtEyIMHJ0uTHm wm5LnBnqugQ84EiBwQMO+9Orm7GNuv9d9G8t+xFWuDmhvBKlaXnp5oXhBiRrbwbaQrPuIEkVD2+h+DYNdOKsqVSyu7W/w1I2OEdZ8qhlIEvfRHuaqf3eddtR /iVFbBCI4vTJxx4+OERoF/OmDUMV+C+iFNWC0LDzARgSe0gVeQV3VthKNrjPtuP4+d8nDd+r7Jub3F14t/Ep2kD8M6A8Po8oWjNxhg== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The c_can_poll() handles RX/TX events unconditionally. It may therefore happen that c_can_do_tx() is called unnecessarily because the interrupt was triggered by the reception of a frame. In these cases, we avoid to execute unnecessary statements and exit immediately. Signed-off-by: Dario Binacchi --- (no changes since v1) drivers/net/can/c_can/c_can_main.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/can/c_can/c_can_main.c b/drivers/net/can/c_can/c_can_main.c index 7588f70ca0fe..fec0e3416970 100644 --- a/drivers/net/can/c_can/c_can_main.c +++ b/drivers/net/can/c_can/c_can_main.c @@ -720,17 +720,18 @@ static void c_can_do_tx(struct net_device *dev) pkts++; } + if (!pkts) + return; + /* Clear the bits in the tx_active mask */ atomic_sub(clr, &priv->tx_active); if (clr & BIT(priv->msg_obj_tx_num - 1)) netif_wake_queue(dev); - if (pkts) { - stats->tx_bytes += bytes; - stats->tx_packets += pkts; - can_led_event(dev, CAN_LED_EVENT_TX); - } + stats->tx_bytes += bytes; + stats->tx_packets += pkts; + can_led_event(dev, CAN_LED_EVENT_TX); } /* If we have a gap in the pending bits, that means we either -- 2.17.1