From patchwork Tue Dec 6 11:57:23 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: 30251 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2774746wrr; Tue, 6 Dec 2022 03:59:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf5ow0HZSoUmtFEMhN+DVjF6iu8QbE5NCxXo0Av3KiZB7wFw7uFLZbmLkaOFCr3Sx5KS0sE/ X-Received: by 2002:a63:f962:0:b0:477:1bb8:bbf4 with SMTP id q34-20020a63f962000000b004771bb8bbf4mr60469860pgk.19.1670327958020; Tue, 06 Dec 2022 03:59:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670327958; cv=none; d=google.com; s=arc-20160816; b=ySCKCoO+qYP7Y2P8xuVcz7wlKQ80nxKocSRljxkqx+aBp0Y62PYroQbqZg4WHiz/LG PasAtGBrtCjBFeSiWg/u5YZoB3TujRwl+s0ICSOjsvfDl4gl7a6xfmXuEBOJ9AP9EBQQ lmdoM51Xd+wvauZwhdR7Zj8BnHw+vhuQaBYDLxm99lRLPYP6k6P5/hHETO4M45iMUADT GUgMlms68T0YG08WSUi2gsrRssVKnt4njvTNoHfUE/kD8qM95BYpfmNgfW2jnmDKBhha LzOq2IG50AwOwaFWFMZxHYRH21aCThFFRtXzcJWq31yu+Gkbi2ilQtmieufPsOCpDDZV vCZA== 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=AsKoU9M+5cIpcCQPCOg/6Uvu2CSKHlAbnecsoPfhR2A=; b=c/xOZg+807O9JfkEHJeCWetVl468++jSmt6PeKem/JrMVzHL2wzheX+ISMoICBog89 OLUl7sxpQK3SqoIbLL19NY1cA24kFDqRLujmT8rtsz031/JNp7+kfzpJDk0xYFEp6LZ3 xNvhR6qasid3zcpR/WTI2Gi0jZWQC1b8R3YyCavzdUyXjO5+PFgH0GX1stllmttGDwzr K0FzJIuJWKSURfEW5tyOJV7zyy7l8bczra6MRd9aSwTAOOu559fN1cXYzro1D9qSJgcn rQgEIP7GMCLdesxGClhkkU/JbxioAeKDUU+CEfuf1egqwMvjK22Yw5LrQG7lWol0T3Mn vmsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=S8E2gky0; 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 x92-20020a17090a6c6500b00219866a29e9si12309776pjj.144.2022.12.06.03.59.04; Tue, 06 Dec 2022 03:59:18 -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=S8E2gky0; 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 S235217AbiLFL5y (ORCPT + 99 others); Tue, 6 Dec 2022 06:57:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234345AbiLFL5o (ORCPT ); Tue, 6 Dec 2022 06:57:44 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C2A05FFE for ; Tue, 6 Dec 2022 03:57:41 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id vp12so5582732ejc.8 for ; Tue, 06 Dec 2022 03:57:41 -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=AsKoU9M+5cIpcCQPCOg/6Uvu2CSKHlAbnecsoPfhR2A=; b=S8E2gky0aD2LAAceaAf9+51yBgoDUwQ456G2qknYvpGcW+Lv1KIaqhFMZFAwnCxkyl mqYFr3NvLPQUJM8f5uQ+00DHBz5y9cw1EVN21AE5Mjg5n3j7GYGERfWykh5L5Q+epIrS iRxkfKU1jo2HLqGNC0K/ZUG7PbJrUxn1NPFJ3kYKaMlf9FWHnFPyI/IVhDDJ8pBX+9KJ Md/wa6c/nTFApV5QUcks/mV7ntMyjveqvnvIMgZDZRn9561Tktlawkq1bDl25OYYgGZn fs/oPsxBMD1bx1vwI/U1Op25szWAu96FHguNXJ4Fm36Zu2+t+1keu7i0nCwFSSiw7HZ1 RAcA== 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=AsKoU9M+5cIpcCQPCOg/6Uvu2CSKHlAbnecsoPfhR2A=; b=bN2BSVucIph+NQpJNlrBjwuWU4KQ7KPKKw3e1+gsAsxkpbepFi1/uCac4ToJYcvE0a arTntu5994Gw6jzaLksK/xfOUFLX5vhRNEVHSBjSNBsNys+BEGHKkzg0Mele9NJLa1aJ 6RFfyFVmzxoQ3LOzEpGLy/J3rtl5nR98RG1suxvI8+UYWcqUTHF+l8mhD6VJ6/Ohzkv7 BuHs7fJvNNdkHodNfRCE5A9BiPYs4JdpWiCPd7MPT+bQLqEDuN8Hhv5OXU/oLjgJ1RGO i7ZRmv/mpATjtuhigRa7G1QnnnUVwydKCkSjzJN53vUhJUkOjrBaiOxwmZBG8NvT6O/i Lrhg== X-Gm-Message-State: ANoB5pkaAJPYKY17ybzcW7JmzsBJVQQ+PZ/JSsaGuJ7GoTu+vcGBS1mn RRy/R3Y8oRqf7p98XOLNavJ7xw== X-Received: by 2002:a17:906:6acc:b0:78d:b371:16e5 with SMTP id q12-20020a1709066acc00b0078db37116e5mr58056102ejs.456.1670327860866; Tue, 06 Dec 2022 03:57:40 -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.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 03:57:40 -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 06/11] can: m_can: Batch acknowledge transmit events Date: Tue, 6 Dec 2022 12:57:23 +0100 Message-Id: <20221206115728.1056014-7-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?1751465808844404545?= X-GMAIL-MSGID: =?utf-8?q?1751465808844404545?= 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 a0ae543d418c..5572a6b3b94c 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1013,7 +1013,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); @@ -1028,28 +1030,29 @@ 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); /* update stats */ 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)