Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1176600rwb; Wed, 16 Nov 2022 13:19:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf6hoNc8hVmuxO7krxn8JgU912EL34r4Vp4CXLGuG30F9IU84xFUZXIhmLjvcWdqUXEiRHEo X-Received: by 2002:a17:906:3e46:b0:78e:1046:c52a with SMTP id t6-20020a1709063e4600b0078e1046c52amr19313053eji.713.1668633540722; Wed, 16 Nov 2022 13:19:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668633540; cv=none; d=google.com; s=arc-20160816; b=Za/O08QwT+L+t8ta4fMxXyPNnu0iiRUfrMYrvixS6KcNsvXZxv4xtZfWdF/HQYll+I 9ASe2UfX+F4Ezjpa8RqGDv5yUCsroYhNpbi9iePbVataA5YKzcsc+91PdIxLpeUjB+mA bVlDd5feT1gcjT4d1E1dt2cx0ZBBsSw8zTHRyVv7hM8eOjrEGKsIi/vxRjoxdFya0VjP 4KEfu6nnVAEi8Ll+jcaAT4N3DnLyPLtSe1q0T7HntLG4Q+6jj9yG1UO6eWKBssxbE1Ri sE7rjRcMj19GtqC0NiBhfvwY0L+YQvJVjipWNsgSI0S38CTiduIIKiOnklVuQFAkCph5 Zz0g== 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=63B61nbFxXevaqifM6unbv7DVTV+dONfI4xcJ7fYbEM=; b=g/3BQZnLQg/xmAfphrK4bpeDWzCZE9yBE9j2p8BIcgH6pGo+i0sIanbZGpoZWH59vb ua88QDX3S0mtMimerXt/sLbi9ra2gw3nKynru2DOdfN3pDJRJO7Bx6dg4r8SX9LhvfvU jP9nF+HKw5f1um1JrIM3f7xBrDIe276+JhdzTQMWs7P3qCQc4UfXn+peAH0fBHNFXVQv /BkZENANSomZPInbNTUx332CcTYzrzT2PebpsPYrBi6XuSlE7SsfclW1LWL0yKcJPqEx 4E6VMe+J5Bn6CPjKV8Beq+BIoz84laGPvkV7Z4ndfp7SeGl64zkM3OjEyQCKqQyeP7XP CiAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=XrxRLv0i; 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 dn2-20020a17090794c200b00781cde43588si18078729ejc.58.2022.11.16.13.18.39; Wed, 16 Nov 2022 13:19:00 -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=XrxRLv0i; 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 S239065AbiKPUy5 (ORCPT + 90 others); Wed, 16 Nov 2022 15:54:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233438AbiKPUx5 (ORCPT ); Wed, 16 Nov 2022 15:53:57 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B60666558 for ; Wed, 16 Nov 2022 12:53:34 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id bj12so47077093ejb.13 for ; Wed, 16 Nov 2022 12:53:34 -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=63B61nbFxXevaqifM6unbv7DVTV+dONfI4xcJ7fYbEM=; b=XrxRLv0ioHvztchOOEylzwIXG5E6/NOIFrU0lDh3B+0C0zkoUMrAFpJRw5jxDREGEQ p6GpjhDPZ5pODwZZUQtgNoFhFAbLTCrl+H6achFwFFRrd/Zy5aTWNvi3Gr5fB7kk2UtA AVAQLiexAir2XBwRfZHloDmCAlDgzVrEK8mSWP+Mox+pGSLt2NJnziGicFxo06eyvGwi +nvJE09r0HP94yDjezRuisu3bCGIabGRbmxdPasO5vG2NO4bfHB6Qo/YcTBQIx+PEVJR SS3NhGa6W/yb9shUV8lZ13ZLOL8QC4CeWXtYPE1BrDK4+jsh/TVT7EjGFDmbzbuwrwFD V7yA== 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=63B61nbFxXevaqifM6unbv7DVTV+dONfI4xcJ7fYbEM=; b=D69MOBMV5h4EzsExUu18yZiz8Cts/ZW7XHUopUiVDCM1fOjGLAMMIofi8IhBsaldrt CcxyVzJf8Vbo4NSxMnflOoN142HShsecF8uF5P/KRSqLwEbfIUKXbCccXqe6ORzviZwm mifGl/aUpiWIapgNPfY0NgHZ1Ily+EgCd/29SBPX+rMmKXgc7c3F4IszYrX7AT+g/JTR EcMnahmGi0NGSFYaFlSow8Z4t5AOc/loTpbuC+w0AbOJS4acATK0GnTrQsE5L2VMpoY+ 6dVkTErraZarfVADDiUs8G/Pz//k4++k05nmo4lEnkR98EUyCCpijF9shpRF4bhh6Rt4 OPXA== X-Gm-Message-State: ANoB5pmkvFUFYgH+zxOvTbGSHYHoyXauXvWbFBKKW8zu6td0PtUxt3JS Ko+nouDEnty84BkqwK5sbq2lRg== X-Received: by 2002:a17:907:2b26:b0:7ae:c460:c65f with SMTP id gc38-20020a1709072b2600b007aec460c65fmr18733831ejc.226.1668632012845; Wed, 16 Nov 2022 12:53:32 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 12:53:32 -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 11/15] can: m_can: Batch acknowledge transmit events Date: Wed, 16 Nov 2022 21:53:04 +0100 Message-Id: <20221116205308.2996556-12-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 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=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 Transmit events from the txe fifo can be batch acknowledged by acknowledging the last read txe fifo item. This will save txe_count writes which is important for peripheral chips. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 6179b9e815ed..347ba8e7d1b3 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1019,7 +1019,9 @@ static int m_can_echo_tx_event(struct net_device *dev) u32 txe_count = 0; u32 m_can_txefs; u32 fgi = 0; + int ack_fgi = -1; int i = 0; + int err = 0; unsigned int msg_mark; struct m_can_classdev *cdev = netdev_priv(dev); @@ -1034,21 +1036,18 @@ static int m_can_echo_tx_event(struct net_device *dev) /* Get and process all sent elements */ for (i = 0; i < txe_count; i++) { u32 txe, timestamp = 0; - int err; /* get message marker, timestamp */ err = m_can_txe_fifo_read(cdev, fgi, 4, &txe); if (err) { netdev_err(dev, "TXE FIFO read returned %d\n", err); - return err; + break; } msg_mark = FIELD_GET(TX_EVENT_MM_MASK, txe); timestamp = FIELD_GET(TX_EVENT_TXTS_MASK, txe) << 16; - /* ack txe element */ - m_can_write(cdev, M_CAN_TXEFA, FIELD_PREP(TXEFA_EFAI_MASK, - fgi)); + ack_fgi = fgi; fgi = (++fgi >= cdev->mcfg[MRAM_TXE].num ? 0 : fgi); --cdev->tx_fifo_in_flight; @@ -1056,7 +1055,11 @@ static int m_can_echo_tx_event(struct net_device *dev) m_can_tx_update_stats(cdev, msg_mark, timestamp); } - return 0; + if (ack_fgi != -1) + m_can_write(cdev, M_CAN_TXEFA, FIELD_PREP(TXEFA_EFAI_MASK, + ack_fgi)); + + return err; } static irqreturn_t m_can_isr(int irq, void *dev_id) -- 2.38.1