Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1162045rwb; Wed, 16 Nov 2022 13:05:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf50xQho24nmucKgZVzu8vjHPbFwXHpCXGt50bDkdJreubmthLEcI6Z1/FHbBos6XIvzJKUl X-Received: by 2002:a17:907:8a06:b0:7ae:3f79:4d0a with SMTP id sc6-20020a1709078a0600b007ae3f794d0amr19544915ejc.120.1668632704095; Wed, 16 Nov 2022 13:05:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668632704; cv=none; d=google.com; s=arc-20160816; b=EYefZB+E9PifEF8cjL8dS98KozDeoU0c3LKkYSwtSC1cB6yY8q7YM1ofsSKqmk438+ uZPkgHVjzRyIu/rRSAefJ1UvDta+2NZnG42kadJW9Ubstf+NYZYBgT/ZUbPReBLn2c/Q hJKy0nUPgMBJFsQdESfwwQnWoOLU2/FEpe5XGE3vj/JQ15ygs+hZsvICaso8py5LPCEs K+3JAF+oh4xr5I1GAfvGttDRALaV+WzM0kXt+Aio5TP6yypx8WyS3E7sDyc+VK0L1tlM eFRSl2bal5I8mfhlkJQRwfoNnKxGsKrXTHXI2b8gNM0IFjHz6KQu6G5YyTm+aMWubvs1 kRIA== 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=35Qy5T8b8nZe0+fVvuZXlmUhh51OUfHfDykDW4uao6I=; b=obXLO0z0TwOtk3ocEG9QvPIxWxtpzgAjpuISrP2fLnDD6TKB13jt2Bjd4hlRPV+Xys /j11nKyxUJ7GSLi9RdjN4PiuDekzR7mBsFkI2H0cA7iWHQv/7znwbmZ+rY/VVRY3JfhF 5eUGgIE9Y+hdn2WGs2i2XX2ftX6mfFBt5UeA1ClKWdLw8C6uUAIUZuYifXzovsRwfg+O 0FUaOSN2s2p2mrZRk2TiQpgQgT5lFGi8a+D/nb62EVCGtMuvgWcX6Z4XqiEG0XyEVQkH p0+m6jDCoGbnjcWCLpqf9ezPiJEkB8bEqgJ94xx2wXExIXqmpCj4wu75Kjjg6xmMQZor UGeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=aNitAnr3; 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 cr16-20020a170906d55000b0078def5c29e6si13731264ejc.531.2022.11.16.13.04.43; Wed, 16 Nov 2022 13:05:04 -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=aNitAnr3; 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 S238529AbiKPUyx (ORCPT + 90 others); Wed, 16 Nov 2022 15:54:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238422AbiKPUx4 (ORCPT ); Wed, 16 Nov 2022 15:53:56 -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 EC12A6478 for ; Wed, 16 Nov 2022 12:53:33 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id n21so6410565ejb.9 for ; Wed, 16 Nov 2022 12:53:33 -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=35Qy5T8b8nZe0+fVvuZXlmUhh51OUfHfDykDW4uao6I=; b=aNitAnr3LnNKd7Q5VxgwDVTqryOo8InS88hIhNw4Tb7wa4GDJxed7sbIf24+anq4l9 q75Js/1GYwp0hJcvNZkTAhj8RGqxK412V4pEGKnVo/d+10Y3oqGoHdJUIIvtzJJQrHfr rBL2myiZiFe/ZOusjxXo/+EAVDyAIr+Mh2eiH8yCdDy88lcjpKV87JePE/ondWp2B0ev uIUFFxsd/up3e5nTvGwZeRIoR59QxqDO7kVLH1BcORpYporP5mYi/uxrVsvBGNUb05IV JYlrYmwHf6bBuWaI/zaH52ZZX0SxFLQYkg4ghpknehpiYMJ7rYplySv0WsZpTswEt2FG ilIw== 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=35Qy5T8b8nZe0+fVvuZXlmUhh51OUfHfDykDW4uao6I=; b=YZNagk9wnau6rsURTmMlmJnaEkRWJoYZhZRwrFJjBVBuGkO/wvqbZJRhLAD0ZIw0SU 6w72r/SBgbyHf7U9EW1Hl8pqX6yO7JHv8gE6HigpvvfeeA1h4twcRigo6CjZs5ucuf/s jwO63CA6D3xhPaRP8CrbooOVB73g0byy3jx6es1Tb0+mgWRYgxUGUhhgzHqrLN51G2Y5 gqOxkbOb8ZnzrrDsPsFL2xLiq8dhxjYqu3popCJuTzSVvn15eJf0PjsOvn01AcLCNYvU jhg7s7pwFTWgSSuvytLq4ePGr1dFTszPUkg1xOz0iXbMCHV5JVNGrMy2qLvmqEEfL32t mMqQ== X-Gm-Message-State: ANoB5pmlM5wCMX31rs3FO63OyE2OOStufy2J1oSdNvdwtaXafQRTJ3Wi xGYNPEnxIVdUrql7CIzfxqxZvw== X-Received: by 2002:a17:907:98b6:b0:7ad:c0ec:7ad4 with SMTP id ju22-20020a17090798b600b007adc0ec7ad4mr18535259ejc.585.1668632012051; 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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 12:53:31 -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 10/15] can: m_can: Batch acknowledge rx fifo Date: Wed, 16 Nov 2022 21:53:03 +0100 Message-Id: <20221116205308.2996556-11-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 Instead of acknowledging every item of the fifo, only acknowledge the last item read. This behavior is documented in the datasheet. The new getindex will be the acknowledged item + 1. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 02fd7fe4e9f8..6179b9e815ed 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -530,9 +530,6 @@ static int m_can_read_fifo(struct net_device *dev, u32 fgi) } stats->rx_packets++; - /* acknowledge rx fifo 0 */ - m_can_write(cdev, M_CAN_RXF0A, fgi); - timestamp = FIELD_GET(RX_BUF_RXTS_MASK, fifo_header.dlc) << 16; m_can_receive_skb(cdev, skb, timestamp); @@ -553,8 +550,9 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota) u32 rxfs; u32 rx_count; u32 fgi; + int ack_fgi = -1; int i; - int err; + int err = 0; rxfs = m_can_read(cdev, M_CAN_RXF0S); if (!(rxfs & RXFS_FFL_MASK)) { @@ -568,13 +566,20 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota) for (i = 0; i < rx_count && quota > 0; ++i) { err = m_can_read_fifo(dev, fgi); if (err) - return err; + break; quota--; pkts++; + ack_fgi = fgi; fgi = (++fgi >= cdev->mcfg[MRAM_RXF0].num ? 0 : fgi); } + if (ack_fgi != -1) + m_can_write(cdev, M_CAN_RXF0A, ack_fgi); + + if (err) + return err; + return pkts; } -- 2.38.1