From patchwork Wed Jan 25 19:50:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 48284 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp456475wrn; Wed, 25 Jan 2023 11:52:57 -0800 (PST) X-Google-Smtp-Source: AMrXdXvIbN76f+SmLrMN8gskwwk0lX0hq0RwscVpsvmyyJs3BcwYr1tYwduRsJpv97SsNF+n0NNr X-Received: by 2002:a05:6a00:1c9d:b0:577:b52:4ec2 with SMTP id y29-20020a056a001c9d00b005770b524ec2mr30042471pfw.29.1674676377414; Wed, 25 Jan 2023 11:52:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674676377; cv=none; d=google.com; s=arc-20160816; b=VCdpv4Jm7YmNIq3tL17yDB0nX5rVMrVPiAEtqa1i3olXhJQHyjARmSbhiv8hBJ3peP 4PXYwTqGHQPiXf45JHavnac9beED9dOgYZyTtgN89Iy1ZKvvVhuS0jtE7bm84hHShCZY xiDiNO3cy0n+1Wj6/C+qhMsMTYHpOSDPpc/yYpxRWYbMD9ctm5oiD31v/3twkAikVOY5 PBPXiARad8Enr9ILapNqsGUyWX+w5ZCuH/78NohkroNuCw27lsZNl1VAA6HPyNGce8DH B2mtu1TZjtDIE/U0Z/2aTFMKB5glAdVKLrSGwro+2po2uZ3js+z23sPpJWRj1P14pDYs xeqw== 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=w2lrVaPRiH6uq0q+cTr4TOtwHEPWA0Tt42PRWTeXIWc=; b=M/jDiaP0Qon6Pz5UVOh/RBGo9ea+iOPvSEPHGe+R/tirpfW0SDo+lDDw75BGyWle6n NUaWX2+sX7ea++4lxJd8RVFg2IIEHMh1zXMA8LSYeRgsSJKKn0zS8mml0L0vaB3oY52S LDhB7FwfosVMwvQlVDXKLn8OJA397MiWDQzqkgI43BPgmNGnCoz95aF4yRaaOAv9qEda wmdFrFy8FsGW2nFaO7v57VMNfDuC+kZnL7MsiZM+uF/LwKouro/NBcU1rawDYQTFyjVQ h4YF4yAfRxHuZP3xSTgaSppYhBgKzECxJVqByOEA5AIzpJznpK0KoyNw9XsbLKw69ERs 5Ebg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=11ddGa4o; 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 s9-20020a056a00178900b0056cb4662b9csi7313284pfg.16.2023.01.25.11.52.46; Wed, 25 Jan 2023 11:52:57 -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=11ddGa4o; 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 S236135AbjAYTwR (ORCPT + 99 others); Wed, 25 Jan 2023 14:52:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235958AbjAYTv4 (ORCPT ); Wed, 25 Jan 2023 14:51:56 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA52259E71 for ; Wed, 25 Jan 2023 11:51:16 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id kt14so50661326ejc.3 for ; Wed, 25 Jan 2023 11:51:16 -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=w2lrVaPRiH6uq0q+cTr4TOtwHEPWA0Tt42PRWTeXIWc=; b=11ddGa4oOpWRyKolQ6bWHrgxflSd66PqlC7gEHln8u92cm2fHxEDuXQnsx+GplqmBF O98ig0tyA/L45rH+GuTFcWtfDbEgD+DIofkW9Yv1Y+p+OYVE99xlTnoGYHRhsubVM9GX APR/+jZdxRoEsuYLoMfCHDXU6glernrMuzuGlfScC5AhjWtCCeLxyiYzKbAcfGPJkVvX iSepxLaqsVnFAx18JoK27x1Df0y9aBmXMPBpaHeWdb42GA45LZopnejDC7+hFCzos3m4 fY+YAr3KM8xWcfNMQEp72xGoUmvZDhbFiwST4iYRWaSG8cdvRHWctuFDeizm4+O1J3Vz dADg== 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=w2lrVaPRiH6uq0q+cTr4TOtwHEPWA0Tt42PRWTeXIWc=; b=le3a3I2hc48wbZku8t3datfaZFA+3WDqgLBO/Uoo2ve1RnK/R+hc92FGBNEywKHZgI 2T01eWwYhhQfTOzBNsXp85tJ0thHNIYh4BitLS2+683U/4hQX2lE5XCOJo6wiw83iV4u FGnTjkuIsbYmKhpsl4q+9zbL5Tl6n1Ni8D8YBb6R5oxe4ZQjEik9ULVAOV/ZLYgJZGkC sloy+OnPMy4ibhPvZs4D4j19Ec2xeaIc7tGbflveXQAqBfxXMGT7HTyw9y6pN/yqlHGZ iJalGTCoM1VD9da0Joprud4A36RypgG6oVe0tkNiXxHcUvQXvsGViHkcnHkkqsK8vAT+ 7umA== X-Gm-Message-State: AFqh2kpdQwy2Wv3Ybnjo24GztatnonJhuuuio6o+vKJ/3FhhTwWLqQ7a BVz/CDSxdUlTgFO3vyZkw30e5g== X-Received: by 2002:a17:907:9548:b0:84d:37d4:7533 with SMTP id ex8-20020a170907954800b0084d37d47533mr29992408ejc.0.1674676276031; Wed, 25 Jan 2023 11:51:16 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a247:815f:ef74:e427:628a:752c]) by smtp.gmail.com with ESMTPSA id s15-20020a170906454f00b00872c0bccab2sm2778830ejq.35.2023.01.25.11.51.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 11:51:15 -0800 (PST) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v2 13/18] can: m_can: Cache tx putidx Date: Wed, 25 Jan 2023 20:50:54 +0100 Message-Id: <20230125195059.630377-14-msp@baylibre.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230125195059.630377-1-msp@baylibre.com> References: <20230125195059.630377-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?1756025457201880320?= X-GMAIL-MSGID: =?utf-8?q?1756025457201880320?= m_can_tx_handler is the only place where data is written to the tx fifo. We can calculate the putidx in the driver code here to avoid the dependency on the txfqs register. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 8 +++++++- drivers/net/can/m_can/m_can.h | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 9d2345f52ddc..83ffb4c0eb4c 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1475,6 +1475,10 @@ static int m_can_start(struct net_device *dev) m_can_enable_all_interrupts(cdev); + if (cdev->version > 30) + cdev->tx_fifo_putidx = FIELD_GET(TXFQS_TFQPI_MASK, + m_can_read(cdev, M_CAN_TXFQS)); + return 0; } @@ -1764,7 +1768,7 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev) } /* get put index for frame */ - putidx = FIELD_GET(TXFQS_TFQPI_MASK, txfqs); + putidx = cdev->tx_fifo_putidx; /* Construct DLC Field, with CAN-FD configuration. * Use the put index of the fifo as the message marker, @@ -1797,6 +1801,8 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev) /* Enable TX FIFO element to start transfer */ m_can_write(cdev, M_CAN_TXBAR, (1 << putidx)); + cdev->tx_fifo_putidx = (++cdev->tx_fifo_putidx >= cdev->can.echo_skb_max ? + 0 : cdev->tx_fifo_putidx); /* stop network queue if fifo full */ if (m_can_tx_fifo_full(cdev) || diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h index 0721faae7886..4437085f63b8 100644 --- a/drivers/net/can/m_can/m_can.h +++ b/drivers/net/can/m_can/m_can.h @@ -102,6 +102,9 @@ struct m_can_classdev { u32 tx_max_coalesced_frames_irq; u32 tx_coalesce_usecs_irq; + // Store this internally to avoid fetch delays on peripheral chips + int tx_fifo_putidx; + struct mram_cfg mcfg[MRAM_CFG_NUM]; };