From patchwork Wed Nov 16 20:53:03 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: 21265 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp57281wrr; Wed, 16 Nov 2022 12:56:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf6sSN0ZDDlL45WnXWovjFwRnilOaaS8/QkJ5AUnVEHCyiIJb/nZxlIjmDeY1L/9qoBLfjWt X-Received: by 2002:aa7:8dc2:0:b0:56b:b520:3751 with SMTP id j2-20020aa78dc2000000b0056bb5203751mr24536287pfr.29.1668632204300; Wed, 16 Nov 2022 12:56:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668632204; cv=none; d=google.com; s=arc-20160816; b=t2JQXyc70yVE4YTYohUE21cNEaz/ciruq+doh0NOmf75fI4IudHFe67PPwdp904GfW tugmSytL8v7qIkFstfATFEYtAVGEtBprGmPgQjnPO2Y4Mx9Llntj6P0/dd3jN8j8ZpVW F760rSD/s6RjvW7k3FdMg0Go57BloYg25+JXsEPkHXOstNlZnb49H2v+ixkjFavRH1kh 4ikwNFWL2i9AnKrfVL3RAjr23mEYq3+V2UouaLMvJdXTokKGts+OaWYmXEFiU+qcoPYZ T4B+Gs8MeCfLbGtGvQCyUJI6KcTXnvwnwl1j0wtFSYki1BP0BhknUvUNdqYwJ8+Ft7aX jz9g== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v2-20020a632f02000000b0046edf48affcsi16755015pgv.399.2022.11.16.12.56.30; Wed, 16 Nov 2022 12:56:44 -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 + 99 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 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?1749687682759184889?= X-GMAIL-MSGID: =?utf-8?q?1749687682759184889?= 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; }