From patchwork Wed Nov 16 20:52:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 21262 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp56994wrr; Wed, 16 Nov 2022 12:55:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf56VRbxRoJE6gx9kS7CANVkqn/Z5+i6+FTgrJLpwY8DFEZHKSgwzuIoVbnmG/AbsSnsT4mD X-Received: by 2002:a17:902:e546:b0:188:4ea8:a685 with SMTP id n6-20020a170902e54600b001884ea8a685mr10706123plf.71.1668632139823; Wed, 16 Nov 2022 12:55:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668632139; cv=none; d=google.com; s=arc-20160816; b=r+YgcGwBw+ribyzGCJIlftDDb2QLldf4tPbRxDewQ+akbDta511+lwgwY0UI4UKd/i x8Rw/b46Jgzxs25aOR/2+REBcoNk6nQez3vp7slIXSwWRDLezSN7ZZD4+DDM9rw3VdNX e04GGd24x/qzZB/2JMK2urU8z0ACWatUq2mBHV+SkmEtYI1R3B8yn6PoFAwz+GRMov1f y6KIqlFsD8x7hUa0FQkF9UKJU7u/k6DnFCuX2B9pK9ycz6jI6uqGyNCDr4ikoxkSRZII 1GuxuwnP4X81bw+ZvGBVetuIFe5k38GRcLAAPrFfP5SqMGVpHmS59ImfM0lYkiNK9weN +bvA== 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=bbjKmVvFBDrESxHm1md/sljGuNuz1laUujygzg6feGk=; b=IsGU9uA2QkQx1ezo2KZ0XNg0DyGTQKwvGg2k04z/OKRkM+j8u+JIFSpyEMaI+DSXx/ 9K0rxiM2Z6wiFzAZk63L8Ab4guHGcaIWVR1J71k/WIplL+ZmcIbh2dzqrmyS7JB+cUIr MluBM167eQLuch68YgQm0vVp6WScqpwYNlvJlNbAeHYa1FICJsokzM2iTVx0hWNSt6m2 iQzgIpogTcaQZ0j7vErmtGpoUVobqyhWZ0S8rwh2ug3NKIJD8MSO2sj6UTFuTXtYokhl jShPZbq/S5bk8ePBa5/vuiiGHdKQ/YX+81uiY2GUqGuUmqGsCvTIyvPI8u56w2sLnhLr rj+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b="B/KjXbxQ"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j18-20020a170902da9200b00178b95aa01fsi17768729plx.614.2022.11.16.12.55.26; Wed, 16 Nov 2022 12:55:39 -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="B/KjXbxQ"; 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 S238962AbiKPUyd (ORCPT + 99 others); Wed, 16 Nov 2022 15:54:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234622AbiKPUxu (ORCPT ); Wed, 16 Nov 2022 15:53:50 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCDE1115C for ; Wed, 16 Nov 2022 12:53:30 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id n12so47099760eja.11 for ; Wed, 16 Nov 2022 12:53:30 -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=bbjKmVvFBDrESxHm1md/sljGuNuz1laUujygzg6feGk=; b=B/KjXbxQuT9Gao+aqZROklxkKnU1p+JXxNuxzuhCtYHY1qTn69DbzDH9lQBT/eNtGu 4cvQiebMBzu2VeLwimrApbHF9QayhwvoyCWlOCRBn8/pI5cMT9/jVYr9FdPjS78n3BFG L1pif1BFc5E4V2kPh8B84h3XUMsGCRsYm5dOaNMhyLQo4J0WKRh/DlSE7T/JBJrD1n0z vvHzwckjHAiqraXNKoeG3vhOgwbAclMQU49UtaQb6AJAR6UYGVjv7SWDu6CwlttxVwQi VRcCrCalM2c6S0NuQeiqn9hJGg01DtEbjpSdHH1RqkJRZOnR6GXu/3esQC8fI16aIqDe Z6pg== 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=bbjKmVvFBDrESxHm1md/sljGuNuz1laUujygzg6feGk=; b=hTJMufPkGexfBONhLSl0r2ue0fwo1x2lo/43MXd/JdG2mSRDdZJ3JBVWKGQZFNMiP/ yIrBH659enRMb3tuBMbhA+WGGtTjiijcYuDzX39nhMLmyVohnkUIf/eLFJ0vygEhIj0A 4OMglAkA/XsbwQ4itwmfufNOvR73f2FM5ZgEq2WbHQChwOdIpKXyKrRPAuW46OUsx8rn wWFShQdHMvdqQST7E69bMlgbr8rTDyECGMgymSOeiX4IYaGd580ANjSWFukCT6n0928h P/Gf4jbBax05Fb2WNe1GqFJUzXEmOusXjBxXpKm8UmLCyWKXGFTZvFTpAs1CdsPI+V+y S+GA== X-Gm-Message-State: ANoB5pnCqUrSqwrYkeGcOThoM0v0Z20FRSJatN3IRi+IcoQpapLA++yJ O338rHtiLR85JdSkvPQtPCciIA== X-Received: by 2002:a17:906:141b:b0:78d:5176:c4d2 with SMTP id p27-20020a170906141b00b0078d5176c4d2mr18738240ejc.532.1668632008850; Wed, 16 Nov 2022 12:53:28 -0800 (PST) Received: from blmsp.fritz.box ([2001:4090:a244:804b:353b:565:addf:3aa7]) by smtp.gmail.com with ESMTPSA id kv17-20020a17090778d100b007aece68483csm6782828ejc.193.2022.11.16.12.53.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 12:53:28 -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 06/15] can: m_can: Avoid reading irqstatus twice Date: Wed, 16 Nov 2022 21:52:59 +0100 Message-Id: <20221116205308.2996556-7-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221116205308.2996556-1-msp@baylibre.com> References: <20221116205308.2996556-1-msp@baylibre.com> MIME-Version: 1.0 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=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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749687614777875541?= X-GMAIL-MSGID: =?utf-8?q?1749687614777875541?= 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 5c00c6162058..0efa6dee0617 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -896,14 +896,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; @@ -947,12 +946,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). @@ -968,8 +967,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). @@ -1080,7 +1082,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; }