From: Markus Schneider-Pargmann <msp@baylibre.com>
To: Chandrasekar Ramakrishnan <rcsekar@samsung.com>,
Marc Kleine-Budde <mkl@pengutronix.de>,
Wolfgang Grandegger <wg@grandegger.com>
Cc: linux-can@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
Markus Schneider-Pargmann <msp@baylibre.com>
Subject: [PATCH v2 02/11] can: m_can: Avoid reading irqstatus twice
Date: Tue, 6 Dec 2022 12:57:19 +0100 [thread overview]
Message-ID: <20221206115728.1056014-3-msp@baylibre.com> (raw)
In-Reply-To: <20221206115728.1056014-1-msp@baylibre.com>
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 <msp@baylibre.com>
---
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
next prev parent reply other threads:[~2022-12-06 11:57 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-06 11:57 [PATCH v2 00/11] can: m_can: Optimizations for tcan and peripheral chips Markus Schneider-Pargmann
2022-12-06 11:57 ` [PATCH v2 01/11] can: m_can: Eliminate double read of TXFQS in tx_handler Markus Schneider-Pargmann
2022-12-06 11:57 ` Markus Schneider-Pargmann [this message]
2022-12-06 11:57 ` [PATCH v2 03/11] can: m_can: Read register PSR only on error Markus Schneider-Pargmann
2022-12-06 11:57 ` [PATCH v2 04/11] can: m_can: Count TXE FIFO getidx in the driver Markus Schneider-Pargmann
2022-12-06 11:57 ` [PATCH v2 05/11] can: m_can: Count read getindex " Markus Schneider-Pargmann
2022-12-06 11:57 ` [PATCH v2 06/11] can: m_can: Batch acknowledge transmit events Markus Schneider-Pargmann
2022-12-06 11:57 ` [PATCH v2 07/11] can: m_can: Batch acknowledge rx fifo Markus Schneider-Pargmann
2022-12-06 11:57 ` [PATCH v2 08/11] can: tcan4x5x: Remove invalid write in clear_interrupts Markus Schneider-Pargmann
2022-12-06 11:57 ` [PATCH v2 09/11] can: tcan4x5x: Fix use of register error status mask Markus Schneider-Pargmann
2022-12-06 11:57 ` [PATCH v2 10/11] can: tcan4x5x: Fix register range of first two blocks Markus Schneider-Pargmann
2022-12-06 11:57 ` [PATCH v2 11/11] can: tcan4x5x: Specify separate read/write ranges Markus Schneider-Pargmann
2022-12-06 16:20 ` Marc Kleine-Budde
2022-12-12 10:54 ` Marc Kleine-Budde
2022-12-13 17:10 ` Markus Schneider-Pargmann
2022-12-13 19:10 ` Markus Schneider-Pargmann
2022-12-13 19:13 ` Marc Kleine-Budde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221206115728.1056014-3-msp@baylibre.com \
--to=msp@baylibre.com \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=rcsekar@samsung.com \
--cc=wg@grandegger.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox