Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1193781rwb; Wed, 16 Nov 2022 13:37:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf4oxYgqZBY2DEUsUBPtAJJN6roNLBBF0vgkHRelt0wBxImceBrLa4CqF928PFbFimfwUWsz X-Received: by 2002:a05:6402:1682:b0:45c:a9d3:d535 with SMTP id a2-20020a056402168200b0045ca9d3d535mr20705978edv.0.1668634631669; Wed, 16 Nov 2022 13:37:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668634631; cv=none; d=google.com; s=arc-20160816; b=JHZZARXHoxEayIfSvjtdVwDIC4b6eTct3JyUR4rwVnume1/fe3pgYSEApH6F7EOELb lhYQzgW7Y6C3iumMFcXyz7MIgrmVhPM+lUCxIpsGbPC+RX1QOAP1pg/9Vzki6PN2xVx4 cMFGZpfODH3xrmf7yrmjtRj1BPqkCdbQHltoxhBDoJOBjlgJ3+BeQN6Gvl9DyCkphtlG wyv9uMdI0AcZFXgdEYepOmDRQ1MDy4EXxZuFaFcGAkoxXWFTRSOum8Ik07IvXovftC3K WavmoFA8SHA/MEHzF6SVImTg38xqOFXP/4xUwX4NXSgDENeu21wirOryzFMaG9QFRzbz sKfQ== 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=b1NW4yffam7J6Z66UeY98X/Lxzuu+uqNj1++GX3J7z0=; b=zIkS7flXVTjxZxiidoGIotonzb9pidfxqDAjpv329NImgNoUDbySbpVHV42GPoZfpR DBdLHrkqKKT2c0bMwE9uHg79x2ct301NfYD8O0l248/UrxL7ivKDLr3RGeL+Nkcx2Tjf hj8NFf+eFq/AEdoRz6jMyGyO8ynJb57n+dlGCDFhNwOhuRB5FIfkcbIPKgNWwyc2AEI7 CiFWpdmpXDaNWhVg/MQqhj4NgQUIDJISl32iM2dx9pwa62EHUXI2R49cKxJoMgkO4KOb Cfc5tWnu7V0Ui7A1oZAZMrQb9Dh8qTRMdiimXm1VIwGd1iNHeZomyEXp7Y/pfn3u8Gk7 XVQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=Fn+pjOi7; 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 o12-20020a170906860c00b007ae37a89b5bsi10861849ejx.601.2022.11.16.13.36.50; Wed, 16 Nov 2022 13:37:11 -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=Fn+pjOi7; 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 S239006AbiKPUyl (ORCPT + 90 others); Wed, 16 Nov 2022 15:54:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237515AbiKPUxw (ORCPT ); Wed, 16 Nov 2022 15:53:52 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B0856272 for ; Wed, 16 Nov 2022 12:53:31 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id n21so6410378ejb.9 for ; Wed, 16 Nov 2022 12:53:31 -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=b1NW4yffam7J6Z66UeY98X/Lxzuu+uqNj1++GX3J7z0=; b=Fn+pjOi7VxZlwBiOMmabPiR+6IHaFVnPkFKbMENKhdrwfdApvpUQBK2DrzSm8UZ3l+ LBgLnkruBLVK5H9Tz3LtB/DxxziqVAKGYdy+2KAVIJ3tPxXMTLxirF7JOIUcPu3bk1s5 Ah2GESoKw9t04qJclb9ZKouemoIya66kpstWZwAR76Ni2A6BXsyOjIau71qtKm2twGCH OZewz/IsWr1KR9xbm3owiIWYvu9j4qJ6AWvx6bzdTD0OK/RnbkqCeFRwpg88Birnm2FI IBOaNk32rlVnzjgJDp+VA4edjSpYwHv/Iw52HlvRGfnLV14A4FTa8v7sbR1UtkAAbsVg JDqw== 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=b1NW4yffam7J6Z66UeY98X/Lxzuu+uqNj1++GX3J7z0=; b=4iQk7Pht3Mz38WKvyoPfJKAmO8CndG4atdxm/AzKNKdXmEw9JDomUUFyoAMqtKmiNO kAZERBT8ftsoMZ1CXBG32533AKnu0rfc4ug3C6+TJfUkye+cIirneQjffMsuyVjyq2BQ 9JUX0ySMGN9U4Peq9LrzWFVPQj2sEnEtvRDOgb/8QkC8IiaPrO3DPoVfggJuuMrRiAt3 6Ws8eYz7xEA5Yi6mpGn2jlF/TVH9GCaFb2uDO6Drvzh/OFvWrXBCqJhUku+TW/tix0Ik RIXd7fd3NPVAAjiMBnsaYm0w4hT62dXfeuq7hzl5/7mxq7xXqvCi7/07iTvhSnqw088n fp5Q== X-Gm-Message-State: ANoB5pnvmeM0zshXq4byabEsn5VsP/uulPvDm7O333cMPEVtnyH1ghYS FB6mF/+vO1/qeDzYNLRAjLMZlA== X-Received: by 2002:a17:906:489a:b0:7b2:73d0:4b9c with SMTP id v26-20020a170906489a00b007b273d04b9cmr6681647ejq.746.1668632010464; Wed, 16 Nov 2022 12:53:30 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 12:53:30 -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 08/15] can: m_can: Count TXE FIFO getidx in the driver Date: Wed, 16 Nov 2022 21:53:01 +0100 Message-Id: <20221116205308.2996556-9-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=ham 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 The getindex simply increases by one for every iteration. There is no need to get the current getidx every time from a register. Instead we can just count and wrap if necessary. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 1d15beaea920..27095a7254dd 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1021,15 +1021,13 @@ static int m_can_echo_tx_event(struct net_device *dev) /* Get Tx Event fifo element count */ txe_count = FIELD_GET(TXEFS_EFFL_MASK, m_can_txefs); + fgi = FIELD_GET(TXEFS_EFGI_MASK, m_can_txefs); /* Get and process all sent elements */ for (i = 0; i < txe_count; i++) { u32 txe, timestamp = 0; int err; - /* retrieve get index */ - fgi = FIELD_GET(TXEFS_EFGI_MASK, m_can_read(cdev, M_CAN_TXEFS)); - /* get message marker, timestamp */ err = m_can_txe_fifo_read(cdev, fgi, 4, &txe); if (err) { @@ -1043,6 +1041,7 @@ static int m_can_echo_tx_event(struct net_device *dev) /* ack txe element */ m_can_write(cdev, M_CAN_TXEFA, FIELD_PREP(TXEFA_EFAI_MASK, fgi)); + fgi = (++fgi >= cdev->mcfg[MRAM_TXE].num ? 0 : fgi); --cdev->tx_fifo_in_flight; /* update stats */ -- 2.38.1