From patchwork Tue Dec 6 11:57:21 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: 30252 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2774770wrr; Tue, 6 Dec 2022 03:59:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf58xIMrWD5LbDq79Cas+vdmd9qgoH2m34LPc3EzWShnuPsk5BHzsA5Q3ercOr5Ah2BJBHml X-Received: by 2002:a17:902:a989:b0:188:d6c7:e7b7 with SMTP id bh9-20020a170902a98900b00188d6c7e7b7mr69917923plb.16.1670327961756; Tue, 06 Dec 2022 03:59:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670327961; cv=none; d=google.com; s=arc-20160816; b=vm7kl57a4TrsWTI9ca59O3OWM5E7KcuULzM6qXt45G+QW8gNUiPOIPGLUxUNS+Jlwl baTZF5GSC05wBiG6IxdHtwLfiMg23CXHvVDlAorB+n4/bhSnP/1S86dlcxa7xbqCRvLq BHTqE8V3boePOhUd5l3GunQ8ZRdb852Xnl+fWkwkpTFFLH63qTy5D91PjxeNtLUXapG+ 93jrTgqo+bkfMk2m9gPCDniUmPPJtWi6q77qN9DJ/tr953BwjqafyjE1vIBVx1bZ3ax3 n5R0ozJSbFn3LgH0/FrnWRnm+W557VfqMmHpmFN+yRSMHbtOcqCyFw3JuoVEcPCdBKEq Bgew== 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=Jg8CR20tG79djQpdFo8U0Y6E9PQi/JvNHqoQZx2uO1Q=; b=Lg4Qn47FPw3A99jEM6ah8tkCFA2cBQNzoD4lMur3Zl7NlZ8KbKqNceN7uI/SdiiZd+ WSzesXGpbn8fcnQd0awLeb21zkUteWQhNy7Nx7+dhghPvXMdHIEe+bKdm3tcu/c/pwED 5mYrJbxzPcOw3cJfMfPI52bMYt/PKhJLWl2FMBdCfijK45O5rb6oVO+JrP0TLN+3rYQq SHcGpvzqDggthg2NW/Iyivv2QmoE8yVVWzrZVfyplEQ1Wuj6f6/XtYTK0aD9mVXGriXJ fRF3gL1pHsNq2TALmZR+zvvxehqQbx+jQtqmjZri1ZT5Rynx9eoN8lj/Bip5hf8yFDhr U07A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=zELG2lnh; 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-20020a639247000000b00477b371dc7bsi17095490pgn.536.2022.12.06.03.59.06; Tue, 06 Dec 2022 03:59:21 -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=zELG2lnh; 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 S234242AbiLFL55 (ORCPT + 99 others); Tue, 6 Dec 2022 06:57:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229780AbiLFL5o (ORCPT ); Tue, 6 Dec 2022 06:57:44 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD18F958C for ; Tue, 6 Dec 2022 03:57:40 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id ud5so5617872ejc.4 for ; Tue, 06 Dec 2022 03:57:40 -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=Jg8CR20tG79djQpdFo8U0Y6E9PQi/JvNHqoQZx2uO1Q=; b=zELG2lnh50u90Jp2YLLVqH4yZCkDv7zMa535EWcQPw1JEmENJog2b3Vqaw170TwLzo Mz0Z8SmeWTO+dx1Wuqlpp0fYpWLBXeqtfqlcCQZ70JmisGnxHt9gDi7T3KbSDRq/ytP9 hOJ1oP74mxN+w1SRByUuzSSnFrUwbbjXn5/yUDUm5d+yU+2mw2E8sTLFVTMtLfuaVQCE w9JaR1YlrXSrq2LmYnEkm41ANlQdDqwshQbgkP3nVdbMCwXWNo8ur1m++gxNIw1Je89n Fj1r+UbVNA+7252hQFEO7reV7YGsMfRiDo7pj5nAZKquSRfB/BQZxVhRqEzcqJfFlJaT GPzQ== 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=Jg8CR20tG79djQpdFo8U0Y6E9PQi/JvNHqoQZx2uO1Q=; b=CpLzQxnBsTxOF1C/PdEaF0s6E/A7V9dLBtnt9A2ESBekq5Kcd5DE7Cgq9+TqeXAx89 BmHuAcwPE8a0aLN4szybsIBsjiHQ1kUGDrf0kRwHARt6kE5sMqn6KMmrW8IqicSprJGu vJQsGVsxcobI31JGlmoaxLLlNyuwe7tvAyusdm8ZJ/r2W/COKU/j7wXa4PC4ghS+LNCp LpPb/e73dhM33sEnGPocFq1ub951kIk04YzL+bygP/z6H09RK22pRcAxYTYr+OEQeLbg RjAwmb7ztdYMuj1GqNdB1BQ78jPHhWsWDE+yMmRx3mcxQWbZXwHZoBAnj8HRvewSy/ir I8CA== X-Gm-Message-State: ANoB5pnys4pGYCa/+MhE0l77bTMlHVW06hJECGNWwKnoqSJ5Yuzex1OU bvzdZbYm8dVVs2YnF/EOQ99zPA== X-Received: by 2002:a17:906:444b:b0:7ad:dd43:5d53 with SMTP id i11-20020a170906444b00b007addd435d53mr54435818ejp.376.1670327859238; Tue, 06 Dec 2022 03:57:39 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a245:805c:8713:84e4:2a9e:cbe8]) by smtp.gmail.com with ESMTPSA id ky20-20020a170907779400b007c0ac4e6b6esm6472076ejc.143.2022.12.06.03.57.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 03:57:38 -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 v2 04/11] can: m_can: Count TXE FIFO getidx in the driver Date: Tue, 6 Dec 2022 12:57:21 +0100 Message-Id: <20221206115728.1056014-5-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221206115728.1056014-1-msp@baylibre.com> References: <20221206115728.1056014-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=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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751465813113879800?= X-GMAIL-MSGID: =?utf-8?q?1751465813113879800?= 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 45c718413abf..a133f15fb90a 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1020,15 +1020,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) { @@ -1042,6 +1040,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); /* update stats */ m_can_tx_update_stats(cdev, msg_mark, timestamp);