From patchwork Wed Nov 16 20:53:04 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: 21267 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp57507wrr; Wed, 16 Nov 2022 12:57:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf7ucRC45LURQcNpo3aCzbSmt/1WE+pOsONKYPk51RKJa67hE5DLLXwzfhtwaj72HQkp6uU9 X-Received: by 2002:a17:90a:19cb:b0:205:fa0b:798c with SMTP id 11-20020a17090a19cb00b00205fa0b798cmr5439289pjj.179.1668632253654; Wed, 16 Nov 2022 12:57:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668632253; cv=none; d=google.com; s=arc-20160816; b=LwcbbBRIaNVta0fJ2zn1PwGilPVCu0oZsTHGbUnyysuZfsCG8Acd8GSweEXsTc/Mzh IYCTbcqO1GjbyoK+NTNqh/DZLL7ij8YX0AulR/Ba5yskgyhYFBOSdYzpARBRD/aqZpMx x6eihnQYF6oZo3pyTiPrK7uvz+R8uxd+I/6ozJJXUWr4bZ+UUuGpL/G3HMyoVoFmYKMg TMXF/nviDd5MtxZIISS+iANcv5wuZn7wkzr8MB0kl9XlWXMWY9+ZKpY149v9HP7Oo8uh YFKAadVsSMBQ18QzKfiiVg/2+5lRTGc5YCls9mn6XWImbIlzIVyeyg+KzjkXo/mq4A4U vZJg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s7-20020a17090a948700b00200b014d2adsi2624204pjo.26.2022.11.16.12.57.21; Wed, 16 Nov 2022 12:57:33 -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 + 99 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 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?1749687733921788322?= X-GMAIL-MSGID: =?utf-8?q?1749687733921788322?= 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)