From patchwork Fri Sep 29 14:12:59 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: 146745 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6f87:b0:13f:353d:d1ed with SMTP id tl7csp3523266rwb; Fri, 29 Sep 2023 12:46:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHOwm+3aomFK3Zzq36Of3LCm9u48rq1THHccfLANXBMtGXTviska3DxGftUmiiqJS/huUdW X-Received: by 2002:a05:6871:70d:b0:1e1:701:9ff7 with SMTP id f13-20020a056871070d00b001e107019ff7mr6010416oap.32.1696016769406; Fri, 29 Sep 2023 12:46:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696016769; cv=none; d=google.com; s=arc-20160816; b=LRhbTVBRa5F204MMED04lVNe/d1CH2/8Xht4vT74DRXc8oFAjVd0Y3Di3cjVUpC7Aq 4rCH6KOdQ1r/WuQ8NoYkPxQBGUml6ME0Bon32QmKZs9iZuPTVv+a6YtsJOb9iNwYawQO AfVcJSWenWcrZ5CHzJErNHZMbB8NDeZ77imH+l/f+wesXb10URnMhUSMIWGRn24P1ub6 ckO5/QS1bO082HIyAsi3e5hjh31jJ5Fkw1XWBzPQ8FA5OlZS7ude0xVtdaarjCIuz6Hr 8Zh6dIt0QTkSRJtOIleyfiUOlidjGRpJirf/J2Kk759jP+yuj9RAo7YNyZDmSnWCX/oR 0kxw== 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=X+rM/QYhS4mcPKAe3LyxGKzK/5QSlJ3sVw7EeYSM6vM=; fh=EtuWLR14IhIbZM+E+fYn4isj1Y+iLrncbbgmHIVUFEQ=; b=cWMHf+Aj+rIsxCMw6+ZUqT8gOUz+pY1DB3lnoV7cGHUWa4UO44N/Mn5qI7bNFHKnoN abOEhT18v3vns5SL/rs9Zhjm0UJBJDAGj2Ti4DRoJARSSRpTPPANtMdqdTLt8v/06Las 9p4U6n5ZDxLJvWJZ9qy9A8eQIRwNeIDUq6t+qVIQ3R0zxX9Oupr/CFoEKE/NnoCelkdZ iVsuJ7SiBPNWY+WKgxFLU2HckF4AFMRliiQSkj/Qyyi2N3ymaToCkyIsHBfc23Snm1FZ iDkJQB8l6bZ8eoPC7OtdP2CDVjvvxArfR0BeadofqzK7MJVmHNj26eiR+wvrVDS/jmOj dWSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=1T2nCuHs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id j72-20020a638b4b000000b00577f7bc56absi22626870pge.100.2023.09.29.12.46.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 12:46:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=1T2nCuHs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 0F86E828DFF5; Fri, 29 Sep 2023 07:14:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233467AbjI2ONm (ORCPT + 20 others); Fri, 29 Sep 2023 10:13:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233276AbjI2ONY (ORCPT ); Fri, 29 Sep 2023 10:13:24 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14DE51B1 for ; Fri, 29 Sep 2023 07:13:22 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-405361bb9f7so146288285e9.2 for ; Fri, 29 Sep 2023 07:13:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1695996800; x=1696601600; darn=vger.kernel.org; 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=X+rM/QYhS4mcPKAe3LyxGKzK/5QSlJ3sVw7EeYSM6vM=; b=1T2nCuHsyJA2sN+PPQ0EoFaDPUdNCO5brki7BZhNU0tSNfpxvV57AMvHdxShrT7xOX AUKVmopnDS9IQzgjegMNnx5Hkq7ZVS4A2pq4LvNuYdkOel773Cus9prnox3YAEAMqu61 4pC4zaQGCFclxPwTLUHtm23N/hMv4a8XRFAgnRHoY47VxtIAnzBM+EG5ldfQCkfwM8lx bh7EdVoldXCJ6HEIduA4W8Aqmsxz9Yq9tmSuhMFFByOUbjBapP7Z03Oy7UiHMIB2452z xPoeTa1JHskE7jQGlSl4wD8bXgJSXrKSqPC7bxCjTBtQOcXEMJ0roZc14kO6Aabin5/1 xi3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695996800; x=1696601600; 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=X+rM/QYhS4mcPKAe3LyxGKzK/5QSlJ3sVw7EeYSM6vM=; b=GEg0frsM919vM1CCxjKHr6ZdcycQlnimZIJ3xA2RtGwrbMPtgy5JMcxkFDfgG5ZC2x D0j6WdHJ6F4tdWeWnj4/Lkjit3tulS8XotezFnIlXJT+J5ssDr3pyfmDID4r0bnZcdck IpyERjEeUBL+23m1aBGJ38IDN5K88g4o6QT0gHVS10MBbGF5yxkMHVee89QqSED6dwXO xjtD2Ynk5IAzedkG8nRgFqh5UkazJwxNILiIAtUGpCjDWPFbWrnA5vrXF/3qN7UdAU4l WB7JctYpuYFkUPsgFFN1bv8+ROp347Rua5dSbW8x/ms6u63tyFbXKDvSkgJukUmwuTx9 eElw== X-Gm-Message-State: AOJu0YwxXJ8oX7VTX6i4Yo9fqygpzDG9Nhqv0K6qVkckU3kbAR/hnJeo im0VPGrXmOGJ1PeKy0hPer5C9Q== X-Received: by 2002:a05:600c:21d1:b0:405:3ae6:2413 with SMTP id x17-20020a05600c21d100b004053ae62413mr3992345wmj.25.1695996800556; Fri, 29 Sep 2023 07:13:20 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a246:8222:dbda:9cd9:39cc:f174]) by smtp.gmail.com with ESMTPSA id t25-20020a7bc3d9000000b00405391f485fsm1513068wmj.41.2023.09.29.07.13.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 07:13:20 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , Simon Horman , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Julien Panis , Judith Mendez , Markus Schneider-Pargmann Subject: [PATCH v6 09/14] can: m_can: Cache tx putidx Date: Fri, 29 Sep 2023 16:12:59 +0200 Message-Id: <20230929141304.3934380-10-msp@baylibre.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230929141304.3934380-1-msp@baylibre.com> References: <20230929141304.3934380-1-msp@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 29 Sep 2023 07:14:36 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778402479766286188 X-GMAIL-MSGID: 1778402479766286188 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 Reviewed-by: Simon Horman --- 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 4e9e5c689b19..645ce0c9fd01 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1503,6 +1503,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; } @@ -1792,7 +1796,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, @@ -1826,6 +1830,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 1e461d305bce..0de42fc5ef1e 100644 --- a/drivers/net/can/m_can/m_can.h +++ b/drivers/net/can/m_can/m_can.h @@ -101,6 +101,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]; struct hrtimer hrtimer;