Message ID | 20230315110546.2518305-12-msp@baylibre.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2262051wrd; Wed, 15 Mar 2023 04:08:34 -0700 (PDT) X-Google-Smtp-Source: AK7set/12W1MIBbtJaT/R4y5vwXSbG9Z/9ZDCdT4wxXkGZGaTwzXWsHSE9vlBIA2sql32taktwTz X-Received: by 2002:a17:90b:3b4b:b0:234:19a1:8690 with SMTP id ot11-20020a17090b3b4b00b0023419a18690mr41510777pjb.26.1678878514622; Wed, 15 Mar 2023 04:08:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678878514; cv=none; d=google.com; s=arc-20160816; b=aYDp+gy8rjRn1CiaigdD9IDxu3LsT/y824BPpxwY981EDg5QAe+YHRtVunHd2OGuKE dULibKEh7ec/4h90gknAqXQ16jqwlf0wQgHZVPs69AUcU2zKM3KcxOyEOcXCAjflz52s Ld35JZ6U33NSpeJPVx3KIg5uaiFVe2IcpCqHgvxr9vbt8F1DLQt7PmArOcpT9gayiGK8 lSCnYHSX3U+zHZjDiosut7YbQYKlJwgaTjMN7X0GmzQJmiklQoLTdkYoF6nr1BAXFwBl UdEclMhbvh6shQLLIV08qDZlcH1tO7xZ4K83lQ/NxuUmbdh1xrLeDdM8MIWATnnf9jiQ Wq0Q== 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=+ZThZMgUyn2/5ZBEZWr8O3JON+m0nr5Da03HtR+hrv4=; b=A4vL5zUjnMtq72yEfAvCvcafGqqGxJpJMuaPQdNwHJ83MGyY7mMPD6H/P63OHCQOfx xzGaDkbhenFtAtbLqWAg7QmYMa6d/UlY9TqeO+baVIwLAavlkFgvWp6o83H4PSsYNjkK zLauwDdZRhnlYSm9OR/AY9VNGgD5hWZ8BYkUr/IlnT/yRxxKF1vn4jYW0cHRbBoB4Bg7 wxwzHTOzI557O68Rugi25GuVYnAe7XZQgKWLZ90mwMbo3wCMvpx0OAcyGsRzksEK5W8l IY9bpqG5ZpVMDSwbnJGqJuGdIgqT7eB2kIx106K40z892WmPY1oaeiyB1p0St/8O1XGO XegA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=1jJdQZBo; 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 x5-20020a17090a6b4500b00233d10c93b9si1340470pjl.179.2023.03.15.04.08.21; Wed, 15 Mar 2023 04:08:34 -0700 (PDT) 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=1jJdQZBo; 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 S231700AbjCOLH2 (ORCPT <rfc822;ruipengqi7@gmail.com> + 99 others); Wed, 15 Mar 2023 07:07:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231717AbjCOLGo (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 15 Mar 2023 07:06:44 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C23C085A6E for <linux-kernel@vger.kernel.org>; Wed, 15 Mar 2023 04:06:35 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id p13-20020a05600c358d00b003ed346d4522so677060wmq.2 for <linux-kernel@vger.kernel.org>; Wed, 15 Mar 2023 04:06:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1678878394; 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=+ZThZMgUyn2/5ZBEZWr8O3JON+m0nr5Da03HtR+hrv4=; b=1jJdQZBohfY1QzhcZD2so0Dyo46RuqJL5F0a2JAIJmVw9FKiwNSCajBvzLErI/1v4J HUWjs90pw38xxhs5Dla/ic9E1QRCaovsRxKxkf7kKfeO5qE/O8h1R3nkbdJFv61ZaEqd Zb9lMQL3RLUuauMISsE8ruR+WuZWJV7Uu9PXyOi9er+qIQWWJ1K3VjVp9W8P4dBKCQ1Q GtAgjTQs7kmcDpmudifb6FmqcorCzYCdMvABjk1ZPygPtXcd2prhgWwzRTMSSHb+lysq J0GT4ToJcATAXE+CGdzBsoCKJTfNng6cYc57GMXImCKFEIY8whIVYP7A4rAYfZjDLIuQ IoTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678878394; 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=+ZThZMgUyn2/5ZBEZWr8O3JON+m0nr5Da03HtR+hrv4=; b=ZgbBjCe0o4/JcLQGn2pYI4mAmFwWPbnfnwztDiORLQ8FfWYlzzxAoVO8zNGbSkyp63 PGFwM/C0YFEOSYcPdrLwwLpDpABE6ZfJUvNfOP7EaFae1OxWaVaoNfZRmaCUO/ljDkqf lk0G0rq9xWxEh/8rZZnzaOTpvVp9oYLZJ73yisC40khbnCX436qtne/Shek1yIAJL3aR AxcNSv7MuZvNz+CJwv17PhERg9lYfdVwpNJ9uX6v2iG1THYqqoLkOZEBQOLP7CnL90Ig aOkbZyxK7AinD+uPeU3JLPIrjJC+0YZDxRGmlbvWeLgVzZYyXsnuNGcyvqnMR9tJwSDp 1WMQ== X-Gm-Message-State: AO0yUKXwXLuRv47NIOHam74cifoWpV+YQfjAioH8WovfDnQ+p6bF5b31 ggP6qXYY+QYSBpY3VC+Fm2gUY43oiMapLDPlk+s= X-Received: by 2002:a05:600c:190c:b0:3eb:38e6:f65d with SMTP id j12-20020a05600c190c00b003eb38e6f65dmr17284068wmq.11.1678878394397; Wed, 15 Mar 2023 04:06:34 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a247:8056:be7d:83e:a6a5:4659]) by smtp.gmail.com with ESMTPSA id l4-20020a7bc444000000b003eafc47eb09sm1460563wmi.43.2023.03.15.04.06.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 04:06:34 -0700 (PDT) From: Markus Schneider-Pargmann <msp@baylibre.com> To: Marc Kleine-Budde <mkl@pengutronix.de>, Chandrasekar Ramakrishnan <rcsekar@samsung.com>, Wolfgang Grandegger <wg@grandegger.com> Cc: Vincent MAILHOL <mailhol.vincent@wanadoo.fr>, Simon Horman <simon.horman@corigine.com>, linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann <msp@baylibre.com> Subject: [PATCH v3 11/16] can: m_can: Cache tx putidx Date: Wed, 15 Mar 2023 12:05:41 +0100 Message-Id: <20230315110546.2518305-12-msp@baylibre.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315110546.2518305-1-msp@baylibre.com> References: <20230315110546.2518305-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=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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760431717075636708?= X-GMAIL-MSGID: =?utf-8?q?1760431717075636708?= |
Series |
can: m_can: Optimizations for m_can/tcan part 2
|
|
Commit Message
Markus Schneider-Pargmann
March 15, 2023, 11:05 a.m. UTC
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 <msp@baylibre.com>
---
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(-)
Comments
On Wed, Mar 15, 2023 at 12:05:41PM +0100, Markus Schneider-Pargmann wrote: > 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 <msp@baylibre.com> > --- > 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 4e794166664a..d5bcce948d2c 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; > } > > @@ -1765,7 +1769,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, > @@ -1798,6 +1802,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 d0c21eddb6ec..548ae908ac4e 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; nit: it might be slightly nicer to do a pass over the code and make putidx unsigned - assuming it is an unsigned value. > + > struct mram_cfg mcfg[MRAM_CFG_NUM]; > }; > > -- > 2.39.2 >
On Thu, Mar 16, 2023 at 10:55:00AM +0100, Simon Horman wrote: > On Wed, Mar 15, 2023 at 12:05:41PM +0100, Markus Schneider-Pargmann wrote: > > 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 <msp@baylibre.com> Nit in my previous email (which I hit send on a little too soon) not withstanding, Signed-off-by: Simon Horman <simon.horman@corigine.com> FWIIW, I am taking a pause in my review now. ... > > diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h > > index d0c21eddb6ec..548ae908ac4e 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; > > nit: it might be slightly nicer to do a pass over the code > and make putidx unsigned - assuming it is an unsigned value. > > > + > > struct mram_cfg mcfg[MRAM_CFG_NUM]; > > }; > > > > -- > > 2.39.2 > >
diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 4e794166664a..d5bcce948d2c 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; } @@ -1765,7 +1769,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, @@ -1798,6 +1802,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 d0c21eddb6ec..548ae908ac4e 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]; };