From patchwork Sat Aug 7 13:07:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 493817 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF831C432BE for ; Sat, 7 Aug 2021 13:09:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A9B116103B for ; Sat, 7 Aug 2021 13:09:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232348AbhHGNJ2 (ORCPT ); Sat, 7 Aug 2021 09:09:28 -0400 Received: from smtp-32.italiaonline.it ([213.209.10.32]:44067 "EHLO libero.it" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232226AbhHGNJZ (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: netdev@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