Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7289397rwb; Tue, 6 Dec 2022 03:59:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf69ESiiwdRhCFy/5T/ygdBK+67im8Jb1kYZVTNrT/gDQFbiS8z/omxWVzm+da4HrDIZWYvm X-Received: by 2002:a05:6a00:2183:b0:574:2104:5657 with SMTP id h3-20020a056a00218300b0057421045657mr67001711pfi.58.1670327984442; Tue, 06 Dec 2022 03:59:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670327984; cv=none; d=google.com; s=arc-20160816; b=xr0CpzPx/XGlygG8i0PGVzDUzFYGpB2YXmXhmdxTB30nYsweyLR821syX0yLbCK2gl 3Yw3T0/6lE8yRefhmBC2Imc0UeIGPRYWJ9yEPyfUzKBUxkzSxDgv3axtIeRdZw0OA4We xmKKukVe1Qw/o0kKd18/ZTxCLe9aGC9Q757m2yKtsS0JIA+u3Y8S6enI7/j/cBkSN9WL Xn407TIsHnHxVe1jb8UyqirboaX4FxORY0PlytSdYceUvfW76e1ebmMUuTOchMlS2mke oBJQSr007yDTpvLNV4e2nABj2jZHzS65WM9SPcWct3FT/uugrANpuKAy7R9+Mv12hV1L zEpA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fPY/i2W9DO4EoXlKXBgjR2RaogZYXbKp1PtuK+1K7lo=; b=KuQxdXOVmouCH5Hj+lnKoQAfc5uexyr8uldZ5IByjFBlBoL6r8HtKmnvExtNdv60m1 KqNpnENXZ5Dy4xUztYnsy9RVxQ/uQRpE/CHZ1On6fWqqKZaUXc+O9t2D+nKSaAMEtjYN EG+IdILIEWfVxat6KuVWfXSbysNskaiQ6XNotyEs78TlRSGc3M6JKiBgbbTnABKNVwlF AsEPMrQneJCIRWqfoAnnlcJsDWLKscOzGVpHsf9BnfamfRhCwOSopQZEHbhD2mFx2Y5H +akeM0MQw5UAvTPwrzQCpzCyzdEjAIQy0qL0v3gFvA4/5qJ2StvhqYccHMbU66iiY6ov nwlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=lHue8XX3; 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 l6-20020a170903120600b00189db2b93b1si5083843plh.377.2022.12.06.03.59.33; Tue, 06 Dec 2022 03:59:44 -0800 (PST) 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=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=lHue8XX3; 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 S234807AbiLFL5q (ORCPT + 80 others); Tue, 6 Dec 2022 06:57:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235108AbiLFL5k (ORCPT ); Tue, 6 Dec 2022 06:57:40 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 071016583 for ; Tue, 6 Dec 2022 03:57:39 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id kw15so2151325ejc.10 for ; Tue, 06 Dec 2022 03:57:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fPY/i2W9DO4EoXlKXBgjR2RaogZYXbKp1PtuK+1K7lo=; b=lHue8XX3/w6oT10x3GOfSeKr/cEhp3RW+YOtl/a9x3yzg+YxzZu2POfZyEOPevFKpg RY3eovz4dJzdelqPaW9ezwc5ctZZ3YdDh2UT3juvKIubGKwaSZ3J0FtyBtFPWQiv1Drl VlzLIN589cuDcToWTH/Dl5+8Y9mZXD9nwa7gHqld/aSVEDKcEU799r8Du8LzTHkQ11KK UeVt3EG3B2/EdKldT/clXPZh4ZVmLYXfJtLCFMeUJM5Kc+EePKo5xLmBzS0o9v75I+cC Iypdn4hRgvQLcMQ7D2r83jh6oCYk4ORN5SuhLHw7MFEgXyeZdOHlbIOz0xI58esuPp0F 2bbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fPY/i2W9DO4EoXlKXBgjR2RaogZYXbKp1PtuK+1K7lo=; b=iwt2jo2ltyqWsMPo7OuPGIAAlsTgumZ5EXACybDFdtvpGE0JzCDKat6OzqY9ZLBR1X Lu3oSKRD5vlQHEDuho8FKFhpsUcbEZYDkD1B76t1UVLaIVU6lvazdYJZiNjQPBE0MQ98 nx+eiOP3k56lu9y6mIWXkGhJJyk4wez/JryHiyXybSbMMtSNGLvM/9u8mqRHuhLAUqTc WYiead++rf8xNwzUgXfqB9Okf6sEuTcHEt1ydl0EQqCL6Y1ItR8Bzps+kOr/t7BIDYHx OJiQb6SQo4KlLNCupyzH8PDYDKKeszuvg1sawT6WhpVq0gPb13vcAw1AaSGIGENAUrHX MlNQ== X-Gm-Message-State: ANoB5pkwAhCCe2U5p/dX67pa0fmqxQv/Ave7HPZDLblEv6qT7DEu3XXU c/H6fZ7D+rOHUFHBqE7pKtOJEA== X-Received: by 2002:a17:906:48d6:b0:7c1:b67:6a28 with SMTP id d22-20020a17090648d600b007c10b676a28mr2000190ejt.2.1670327857491; Tue, 06 Dec 2022 03:57:37 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a245:805c:8713:84e4:2a9e:cbe8]) by smtp.gmail.com with ESMTPSA id ky20-20020a170907779400b007c0ac4e6b6esm6472076ejc.143.2022.12.06.03.57.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 03:57:37 -0800 (PST) From: Markus Schneider-Pargmann To: Chandrasekar Ramakrishnan , Marc Kleine-Budde , Wolfgang Grandegger Cc: linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v2 02/11] can: m_can: Avoid reading irqstatus twice Date: Tue, 6 Dec 2022 12:57:19 +0100 Message-Id: <20221206115728.1056014-3-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221206115728.1056014-1-msp@baylibre.com> References: <20221206115728.1056014-1-msp@baylibre.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,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 For peripheral devices the m_can_rx_handler is called directly after setting cdev->irqstatus. This means we don't have to read the irqstatus again in m_can_rx_handler. Avoid this by adding a parameter that is false for direct calls. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 0cc0abde9b1d..d30afbb3503b 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -895,14 +895,13 @@ static int m_can_handle_bus_errors(struct net_device *dev, u32 irqstatus, return work_done; } -static int m_can_rx_handler(struct net_device *dev, int quota) +static int m_can_rx_handler(struct net_device *dev, int quota, u32 irqstatus) { struct m_can_classdev *cdev = netdev_priv(dev); int rx_work_or_err; int work_done = 0; - u32 irqstatus, psr; + u32 psr; - irqstatus = cdev->irqstatus | m_can_read(cdev, M_CAN_IR); if (!irqstatus) goto end; @@ -946,12 +945,12 @@ static int m_can_rx_handler(struct net_device *dev, int quota) return work_done; } -static int m_can_rx_peripheral(struct net_device *dev) +static int m_can_rx_peripheral(struct net_device *dev, u32 irqstatus) { struct m_can_classdev *cdev = netdev_priv(dev); int work_done; - work_done = m_can_rx_handler(dev, NAPI_POLL_WEIGHT); + work_done = m_can_rx_handler(dev, NAPI_POLL_WEIGHT, irqstatus); /* Don't re-enable interrupts if the driver had a fatal error * (e.g., FIFO read failure). @@ -967,8 +966,11 @@ static int m_can_poll(struct napi_struct *napi, int quota) struct net_device *dev = napi->dev; struct m_can_classdev *cdev = netdev_priv(dev); int work_done; + u32 irqstatus; + + irqstatus = cdev->irqstatus | m_can_read(cdev, M_CAN_IR); - work_done = m_can_rx_handler(dev, quota); + work_done = m_can_rx_handler(dev, quota, irqstatus); /* Don't re-enable interrupts if the driver had a fatal error * (e.g., FIFO read failure). @@ -1078,7 +1080,7 @@ static irqreturn_t m_can_isr(int irq, void *dev_id) m_can_disable_all_interrupts(cdev); if (!cdev->is_peripheral) napi_schedule(&cdev->napi); - else if (m_can_rx_peripheral(dev) < 0) + else if (m_can_rx_peripheral(dev, ir) < 0) goto out_fail; } -- 2.38.1