From patchwork Wed Nov 16 20:52:54 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: 21258 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp56782wrr; Wed, 16 Nov 2022 12:55:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf7/R2w8f2iOUfH7rF2sh9iYFWjGrssJOytbr+slPMXCrRCylZIyxV/OwR7VYaS+VYTH19iw X-Received: by 2002:a17:907:766f:b0:78d:4795:ff1f with SMTP id kk15-20020a170907766f00b0078d4795ff1fmr19591941ejc.331.1668632101982; Wed, 16 Nov 2022 12:55:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668632101; cv=none; d=google.com; s=arc-20160816; b=h2uron8ZO48DrnG79O8Jc2D3ejqgeTSJRg2ysjvORGYTn46dbHZ4VVBGIg70xz4juT VN1eZSzLOnOvF36mxMyBejIEhFypLrbM2FIXmcC8RbhhPJutHRJ76WkMyLGkLt6lIaUm MCag+N1PZtjQFuRIMvN1YymS4NUfBSBHZyaM88qxC4gOKCkT/dYlruR4l1ulNMX/4vCr 3gCAtKNoChvkZSgzsamtxNeF/wuZ0s/3IrjLGIcEn234wNBCQRAU7FAhFeSzaVyo9rqW Z8M4G4xCPrqAOXNcOQ/iwB0GB3FEzL+DFSrv4SOtfx3RHLj2umnVLGHgBXynLdNpB+D0 qQug== 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=2rJ/wCekKfh+/zbab0KIF63OXyhft6t7a9cE754TRYE=; b=b95nAoDxTNvOiK1Nh6ZJXbh5Wl8vahhGC1BoVgvPFY2G7PYaVx1Gtu6R4m/DjYj3eQ fAraHpkSbjj8rp4bqsTvvJllFuzS1KNbj+65HYzmS2MmmAPukgng0/UXPn9t+VlTKGSe MREiR5kxVbJ0D8IuvkoE/TlFgH1hIN08AVPh4Snarp8fTvty7SKzgqK5LaHfKAdLmt+j GkpuOafyHqLgk7y8Q8pWd4XSudHjpwLe6Pkha+mFS3FVnzdDR0Y7htlLb52NdRTTc6wA MK9fQY7Zl48S5zf8+cXoVPeyOJnFASKGcuNyhrnhSL8KznUp4424QKzEXr/+9uRardlf wK6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=P2To7HYy; 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 cs19-20020a170906dc9300b007af13652caasi6394010ejc.325.2022.11.16.12.54.39; Wed, 16 Nov 2022 12:55:01 -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=P2To7HYy; 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 S238806AbiKPUyL (ORCPT + 99 others); Wed, 16 Nov 2022 15:54:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233340AbiKPUxo (ORCPT ); Wed, 16 Nov 2022 15:53:44 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4C10D89 for ; Wed, 16 Nov 2022 12:53:25 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id n20so98457ejh.0 for ; Wed, 16 Nov 2022 12:53:25 -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=2rJ/wCekKfh+/zbab0KIF63OXyhft6t7a9cE754TRYE=; b=P2To7HYyeZgnQrgVSiKYZjY/MFYOIWjd/XCA+rlJONO4UE9NbuRNNXqh4OoyMZDMFD 8Jf5jjQg1yf4Vyr1mTAAW8m6RnMK0YsErEsVDcNgxGXty8Ezc6tEkn/cflJkqTKCAMtP GZ7exwXlAMjj1At6Tc/0RmiIDNSF1RMyZg3yIdEIJLGYXi1ucQ7ODKnL+s0di9XHxfaQ slvIwH/ocjac5SAAfER5A1IWBuhmNTJ+e/WhRYA/VeSeEWyGUUyumYgQbgc6gQMyylXG TOVZtkibuNn46tWev4OobR6gdDQVrGUxaw0tXDwxjwLTmKrHDf5404mUyxGyYeqnyRSa HUyw== 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=2rJ/wCekKfh+/zbab0KIF63OXyhft6t7a9cE754TRYE=; b=Oc62xkx8PN7ZMX42VHXAhrUkOD0PD2QXzNcovsQqIQRvv5YINLbL37GcNRfepS/XQY g5IcmZbQLRfFyvaknSzd8oegPITdGClcltjazgSwEUEc5eCz9/JvCJ7CrmQkaL05lQEY EfGVvqkAkaD7axdH/nTJ5ioJ0u27MZqa+CeNHTHiG/fMsrxNLIdaWaROriMP38BZAsWd w8HiYoltmX7YMXXA+7QCt0TTH5xQDa59uNuHH03QZiGSLahTB6GQC7wmEl9d9qhdUHVt v05sTdAGfn8cez7vSxlBmw/GXxyi3Chg9oSFlZEXiMp/dqqIKPl8i3ueuPSPHX0nDK9+ LSGQ== X-Gm-Message-State: ANoB5pmb8PlhRdQa1nBt1rxcsDyeN1VeXN/YWJDenC99Y8/j4dKz+K2L Wzm/fDGkM6r0wjSzdXyAIqSBkQ== X-Received: by 2002:a17:906:1248:b0:7ad:f9da:8986 with SMTP id u8-20020a170906124800b007adf9da8986mr19202437eja.54.1668632004349; Wed, 16 Nov 2022 12:53:24 -0800 (PST) Received: from blmsp.fritz.box ([2001:4090:a244:804b:353b:565:addf:3aa7]) by smtp.gmail.com with ESMTPSA id kv17-20020a17090778d100b007aece68483csm6782828ejc.193.2022.11.16.12.53.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 12:53:23 -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 01/15] can: m_can: Eliminate double read of TXFQS in tx_handler Date: Wed, 16 Nov 2022 21:52:54 +0100 Message-Id: <20221116205308.2996556-2-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221116205308.2996556-1-msp@baylibre.com> References: <20221116205308.2996556-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?1749687575246571356?= X-GMAIL-MSGID: =?utf-8?q?1749687575246571356?= The TXFQS register is read first to check if the fifo is full and then immediately again to get the putidx. This is unnecessary and adds significant overhead if read requests are done over a slow bus, for example SPI with tcan4x5x. Add a variable to store the value of the register. Split the m_can_tx_fifo_full function into two to avoid the hidden m_can_read call if not needed. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 00d11e95fd98..2c01e3f7b23f 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -368,9 +368,14 @@ m_can_txe_fifo_read(struct m_can_classdev *cdev, u32 fgi, u32 offset, u32 *val) return cdev->ops->read_fifo(cdev, addr_offset, val, 1); } +static inline bool _m_can_tx_fifo_full(u32 txfqs) +{ + return !!(txfqs & TXFQS_TFQF); +} + static inline bool m_can_tx_fifo_full(struct m_can_classdev *cdev) { - return !!(m_can_read(cdev, M_CAN_TXFQS) & TXFQS_TFQF); + return _m_can_tx_fifo_full(m_can_read(cdev, M_CAN_TXFQS)); } static void m_can_config_endisable(struct m_can_classdev *cdev, bool enable) @@ -1585,6 +1590,7 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev) struct sk_buff *skb = cdev->tx_skb; struct id_and_dlc fifo_header; u32 cccr, fdflags; + u32 txfqs; int err; int putidx; @@ -1641,8 +1647,10 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev) } else { /* Transmit routine for version >= v3.1.x */ + txfqs = m_can_read(cdev, M_CAN_TXFQS); + /* Check if FIFO full */ - if (m_can_tx_fifo_full(cdev)) { + if (_m_can_tx_fifo_full(txfqs)) { /* This shouldn't happen */ netif_stop_queue(dev); netdev_warn(dev, @@ -1658,8 +1666,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, - m_can_read(cdev, M_CAN_TXFQS)); + putidx = FIELD_GET(TXFQS_TFQPI_MASK, txfqs); /* Construct DLC Field, with CAN-FD configuration. * Use the put index of the fifo as the message marker, From patchwork Wed Nov 16 20:52:55 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: 21260 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp56862wrr; Wed, 16 Nov 2022 12:55:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf5rOC9QgI6QmRGZ4Xpxq9fvAZ4oyRxhQJuh0fe4ibbg2JOBkxdjir5n4dYEnLIGhHeoK5jJ X-Received: by 2002:a17:906:2354:b0:7ad:c8d6:bc7f with SMTP id m20-20020a170906235400b007adc8d6bc7fmr18806808eja.118.1668632116083; Wed, 16 Nov 2022 12:55:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668632116; cv=none; d=google.com; s=arc-20160816; b=nqjL4kEhWKU4G3KaF99WM/aybcPAfX3G7qnGiND2d/E+yV/621kma6UmXPlBU2AoQM aY4yfZlUS9LxYosMVTGj7bwGAUdpv8iaDPIpCAKJI1d2u7PU92sGsjA3HETYZIgo2oKg bDqAh5PCR8zyptUr6Qms3tXrPSow5QgcNeNQoCJ7uMpv30vl9bveS2jWni/m/Qic4jdG qp4aBPtsok3vjD2b8lJt2xk2s1PXx3rfjGMUVIDjcCkBzLbe3wpfcHW819xWw7qUeL9z Rk0mdRTDmMBWKCtmCLuKdcZjT7cGRivB5LhkbbH4N/BMmNhe2hOHvzkNyIGxQijyUmYJ bTEg== 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=ajsZbX3+twaGsWlZnthQH+DJqMTcB864bD+ktj1XJi8=; b=ExUmeBvNWXR+viXEgmakMc4H8ZUJGdos/N6GuyCxfff9h/SPZ9kus0Z39yxHElHLzF YS+p65G61zqV7glMw9hiVldPWXezr1kf/sOSld2mpKc9pX8wR/nQ/IoqKQf+E5kdPyP9 7vPhD+HtMj3Tx3ORZqZ1Dd/Z4UgQUdLVftix2p7/t84Y3NXZJPkvE7/rtf5yTxLJWrje WGp43LvlpvBJfBrCSY7G9OO2Y/mzXgeVD7NC9pd+VJxHjSJ5Zof8gXg8OZH67jwwYv2T O7YhBbDQ2W/cAKBP0n4B0wdJzsD/GY9ieVgTYpBL+jjBW9YwhGibkmAyeVvBLp9U4mXU rKMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=cGyV6iSy; 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 k16-20020a17090666d000b00787abcb1ce0si13792674ejp.679.2022.11.16.12.54.52; Wed, 16 Nov 2022 12:55:16 -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=cGyV6iSy; 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 S237236AbiKPUyV (ORCPT + 99 others); Wed, 16 Nov 2022 15:54:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234040AbiKPUxq (ORCPT ); Wed, 16 Nov 2022 15:53:46 -0500 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5752E27 for ; Wed, 16 Nov 2022 12:53:27 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id z18so28438557edb.9 for ; Wed, 16 Nov 2022 12:53:26 -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=ajsZbX3+twaGsWlZnthQH+DJqMTcB864bD+ktj1XJi8=; b=cGyV6iSyzBue0i5l97tQs1F/+bVMjgHav1MAY5Sp3ebIBKAF7rtEZUC/JmhiwCz45R rRQmwP4+vYFx1HAHkCDFG483CrsfEqHCo+WCCTFlJMKBWpByz9CHRlXEaEQXB15nQPg4 dVsPlUsn/h1qq8jjY1MBSrqbPNamW8aseozcmaPGAq5PLnSUxm1OYs1RIplM/W+npToS w+3jyD1we20/rAh/289ilWSbioDeGmbslRMCVMzHBoPyp6ZqDInmObMZhFFeJfhVg5b/ iuEhPle4TOpHkI0KN4kdg09gqWy6Y6GZf3f7H+fUL6eCG+EP6tv6oKJnBQ1vawL2Zg8+ FgpA== 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=ajsZbX3+twaGsWlZnthQH+DJqMTcB864bD+ktj1XJi8=; b=Iugrfh0fgXKug1UE6XoItx5uTaWQxWS8k+OXT+OjeOfbLTojaUwKLqBIXzFbEf8fk9 CjFLZuJnQ5wEtPqt55x9W2dCh3XFz6uBcoIKazI3VrdTT7uBOj3i57xmLG3/wJdimRuu KtJ/cMosNnT1kE5amh0lUxLFY4+z8tTt4vSZGj0bOB2LekioOI2ojG4lece9ArZENngF zwRHzkWWakr5JSariphkRQZ0D1Jfekl2i5/DyJNwoZUoFEB+ObjiCkXxZh5GR1vkQ0Ci l6eUPKJjCKVy1fMaOxIMXmcSZtITtDw5Y0/8lqjebNQe1jwabpFEUnGQiGe/2DFqSsA+ /oIg== X-Gm-Message-State: ANoB5pnEOtnatlGQWDmg1FL1pUl8DZIGT/DjXUQaXd5gEDF6dHWmAarL AKhUZHb+gQhEWhlBFobZmg1h9Q== X-Received: by 2002:aa7:d6cb:0:b0:467:e2dd:b593 with SMTP id x11-20020aa7d6cb000000b00467e2ddb593mr12985138edr.378.1668632005445; Wed, 16 Nov 2022 12:53:25 -0800 (PST) Received: from blmsp.fritz.box ([2001:4090:a244:804b:353b:565:addf:3aa7]) by smtp.gmail.com with ESMTPSA id kv17-20020a17090778d100b007aece68483csm6782828ejc.193.2022.11.16.12.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 12:53:24 -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 02/15] can: m_can: Wakeup net queue once tx was issued Date: Wed, 16 Nov 2022 21:52:55 +0100 Message-Id: <20221116205308.2996556-3-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221116205308.2996556-1-msp@baylibre.com> References: <20221116205308.2996556-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?1749687589428357681?= X-GMAIL-MSGID: =?utf-8?q?1749687589428357681?= Currently the driver waits to wakeup the queue until the interrupt for the transmit event is received and acknowledged. If we want to use the hardware FIFO, this is too late. Instead release the queue as soon as the transmit was transferred into the hardware FIFO. We are then ready for the next transmit to be transferred. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 2c01e3f7b23f..4adf03111782 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1097,10 +1097,9 @@ static irqreturn_t m_can_isr(int irq, void *dev_id) /* New TX FIFO Element arrived */ if (m_can_echo_tx_event(dev) != 0) goto out_fail; - - if (netif_queue_stopped(dev) && - !m_can_tx_fifo_full(cdev)) + if (!cdev->tx_skb && netif_queue_stopped(dev)) netif_wake_queue(dev); + } } @@ -1705,6 +1704,8 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev) if (m_can_tx_fifo_full(cdev) || m_can_next_echo_skb_occupied(dev, putidx)) netif_stop_queue(dev); + else if (cdev->is_peripheral && !cdev->tx_skb && netif_queue_stopped(dev)) + netif_wake_queue(dev); } return NETDEV_TX_OK; From patchwork Wed Nov 16 20:52:56 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: 21261 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp56889wrr; Wed, 16 Nov 2022 12:55:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf7lZ7g4ZKWxiAaldVU9qxcfNDzaHRp5ek4+/Oxr8QwkuOljlarv/avj3i6OzXocHn2t48yh X-Received: by 2002:a17:906:349b:b0:7a1:e4c2:fb0b with SMTP id g27-20020a170906349b00b007a1e4c2fb0bmr19026819ejb.464.1668632120764; Wed, 16 Nov 2022 12:55:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668632120; cv=none; d=google.com; s=arc-20160816; b=uzW/1AmvvQGpL9z+Yfs1ZnzXvT73HCfxal+pYwQtvXc6JtrD9Q4bVvpiSncHrPfHWr 3ccz6yXscbQAFl1ISxd1+ODvS8QwXuxJBFlHM5xz8pTP+erckkmO9E+oCVDo5P5xsKrL C2KlPqbhiKu+cl7shT8VMEHo/D5KdVt2LNAygyYo/k3g5UrI7VoOHAp4aoncYh54VYAR zlPdO704Wy9pzMyRESDYNDW18HdCcMipAb+JyGx2DGxS4AeB5pHTGDWRnVWAKnhcFfNL fblSKus55xF6HCkOwhWix8wAKYE3b4QatP2jscRK8FbK3msf03Tf4NayOFLqwjNOOq7x YP3Q== 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=ymKWfG3hBUHC+wOiiQxZhyFHyJiOcWTWeXnW4/XpvSQ=; b=l79So47EUGbd5iKLG5CSaCAnHFcp0mw2Xkd2+65FnRt6wWhkeLZBfojRWUVC8yvOux 2NYkWzjGR5WlWJJOMLKzmij6g4qMy4u/hmtdtcGYvP4m3DiM6IiOqECoKiccPH2m4f8z BSEEMCYYTot8Iqa7yv8C0giyyFkpxZZEmSK241H/7jLJD7ysYtB4uk1B4RwhJ9rf4PAS f4cSAuWmri7s9+Zon9foeymxFf0poQU94Rr0Rw16Hv+jCwXejH2Gg5JennwehvH12Spj 9R+ZEN2M/a3+5nZ789Pi7LN77mLpCJ/lxnH1simlxi5U0T/6SHlagxBr49fYjznNNCEH gECg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=uBIdtaeG; 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 sc36-20020a1709078a2400b007ae832c0b6bsi15734608ejc.508.2022.11.16.12.54.57; Wed, 16 Nov 2022 12:55:20 -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=uBIdtaeG; 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 S238928AbiKPUy0 (ORCPT + 99 others); Wed, 16 Nov 2022 15:54:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234223AbiKPUxq (ORCPT ); Wed, 16 Nov 2022 15:53:46 -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 44037E37 for ; Wed, 16 Nov 2022 12:53:27 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id ud5so47209917ejc.4 for ; Wed, 16 Nov 2022 12:53:27 -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=ymKWfG3hBUHC+wOiiQxZhyFHyJiOcWTWeXnW4/XpvSQ=; b=uBIdtaeGMMK0etaJ10sYW6BxgNAyYojLXCGy0W42C+OfWLPOupay7/r0gtDdbrusfx UMGtFFUhGTNuo62g/z04us3xcWWsJylHgFAzaLUOKDz4nkF7I6lR5JYF1XR+1z9PCcMO SWZ5+W2N46uWnqy/y4Iec02er6vZlbge75TGJyzfM44ovW2lte7VHobLp4A7N+P1kHiE hSV2cRdrnkUqf3fhiHpB7Ya2OHa2borOYj/kxMXgVL392o4f21DoNWSwft4nNhJSLfM6 O54h8A2SVNF+4tTC6/YQnzgL/WfzCj9ZIJUkJ3wnyAi1hCo1xrSRnjhVaINTIrKp94SE Jm3g== 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=ymKWfG3hBUHC+wOiiQxZhyFHyJiOcWTWeXnW4/XpvSQ=; b=NK4SjOOtoAS/VfW8pLmgus5qW5eeliR10SOVxy2J0SHvWTMwYmiKL5nFoHBKJiqFzs ENyJ1+8xq11Z/vMGVrjE668sFxnNYzyWpM+A1tfrdf/xrJUtKFT17LGNgrZ4/Je6SNwI Rez9hfnCbk/0yKD3sLsuY1HUFeCPiJIgZEtaWib4+4iFfcGy7Or8JBKl6gdwWtXUjUFC GyaBtDLuCzHclTgcj6gCHAEymjQJ4KAKWBEQnG60p7bGwt68Q5pOwvZKxX8HSUgDMIO9 HTZOc0bhqKkJhYOHotT8LmDnI2voyfn67UQvHQPM15CJ41aZLzs4D8H9yxc9ZEYDlFEd /Frw== X-Gm-Message-State: ANoB5plv2nei1JTjp52HTFgXZ3CeWLmW/o/65ykqf3xFKL5n2e97RLVS nXU4Vp4iwCtRXaCmAMRa+1AlrBdZh11lbA== X-Received: by 2002:a17:906:49c2:b0:79f:e0b3:3b9b with SMTP id w2-20020a17090649c200b0079fe0b33b9bmr18729246ejv.378.1668632006474; Wed, 16 Nov 2022 12:53:26 -0800 (PST) Received: from blmsp.fritz.box ([2001:4090:a244:804b:353b:565:addf:3aa7]) by smtp.gmail.com with ESMTPSA id kv17-20020a17090778d100b007aece68483csm6782828ejc.193.2022.11.16.12.53.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 12:53:26 -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 03/15] can: m_can: Cache tx putidx and transmits in flight Date: Wed, 16 Nov 2022 21:52:56 +0100 Message-Id: <20221116205308.2996556-4-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221116205308.2996556-1-msp@baylibre.com> References: <20221116205308.2996556-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?1749687594416988650?= X-GMAIL-MSGID: =?utf-8?q?1749687594416988650?= On peripheral chips every read/write can be costly. Avoid reading easily trackable information and cache them internally. This saves multiple reads. Transmit FIFO put index is cached, this is increased for every time we enqueue a transmit request. The transmits in flight is cached as well. With each transmit request it is increased when reading the finished transmit event it is decreased. A submit limit is cached to avoid submitting too many transmits at once, either because the TX FIFO or the TXE FIFO is limited. This is currently done very conservatively as the minimum of the fifo sizes. This means we can reach FIFO full events but won't drop anything. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 21 +++++++++++++++------ drivers/net/can/m_can/m_can.h | 5 +++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 4adf03111782..f5bba848bd56 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1041,6 +1041,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)); + --cdev->tx_fifo_in_flight; /* update stats */ m_can_tx_update_stats(cdev, msg_mark, timestamp); @@ -1376,6 +1377,14 @@ static void m_can_start(struct net_device *dev) cdev->can.state = CAN_STATE_ERROR_ACTIVE; 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)); + cdev->tx_fifo_in_flight = 0; + cdev->tx_fifo_submit_limit = min(cdev->mcfg[MRAM_TXE].num, + cdev->mcfg[MRAM_TXB].num); + } } static int m_can_set_mode(struct net_device *dev, enum can_mode mode) @@ -1589,7 +1598,6 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev) struct sk_buff *skb = cdev->tx_skb; struct id_and_dlc fifo_header; u32 cccr, fdflags; - u32 txfqs; int err; int putidx; @@ -1646,10 +1654,8 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev) } else { /* Transmit routine for version >= v3.1.x */ - txfqs = m_can_read(cdev, M_CAN_TXFQS); - /* Check if FIFO full */ - if (_m_can_tx_fifo_full(txfqs)) { + if (cdev->tx_fifo_in_flight >= cdev->tx_fifo_submit_limit) { /* This shouldn't happen */ netif_stop_queue(dev); netdev_warn(dev, @@ -1665,7 +1671,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, @@ -1699,9 +1705,12 @@ 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_in_flight; + 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) || + if (cdev->tx_fifo_in_flight >= cdev->tx_fifo_submit_limit || m_can_next_echo_skb_occupied(dev, putidx)) netif_stop_queue(dev); else if (cdev->is_peripheral && !cdev->tx_skb && netif_queue_stopped(dev)) diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h index 4c0267f9f297..7464ce56753a 100644 --- a/drivers/net/can/m_can/m_can.h +++ b/drivers/net/can/m_can/m_can.h @@ -92,6 +92,11 @@ struct m_can_classdev { int pm_clock_support; int is_peripheral; + // Store this internally to avoid fetch delays on peripheral chips + int tx_fifo_putidx; + int tx_fifo_in_flight; + int tx_fifo_submit_limit; + struct mram_cfg mcfg[MRAM_CFG_NUM]; }; From patchwork Wed Nov 16 20:52:57 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: 21259 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp56807wrr; Wed, 16 Nov 2022 12:55:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf5hxnTfcLFNkNm+ut/HZ3N+zhwKREM2lxprk3JsFb7VVLAQmlrTkmrhyXBbdCzEJ46ScRHC X-Received: by 2002:a05:6402:2c8:b0:461:1f4c:36d0 with SMTP id b8-20020a05640202c800b004611f4c36d0mr19986613edx.310.1668632106057; Wed, 16 Nov 2022 12:55:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668632106; cv=none; d=google.com; s=arc-20160816; b=k4sJWtwgJjjH/N5r0a2vKQlp2pLUNcpsQtwrchHE/8vU1eImTzxflhSdQc6wO26WOb C2bSSRNAcRBOQRFTfsiB9rVLjm26xmBRecCzMTt33IzxJV9eKeW5SCrM7fgW12Kpq2vL DAnHoCOUnZnZC2I4WrhvEus6MHsIRvHorf4M91oL4G9KT53nbHvaBGYUWzkmE/RkAlbz sUPLGAwYM4eIrPf1NibqqFeUI7ijKZby33YQKx9BckpEXwrXk64Zu36rBusyUJbaJejx tstFPprgD7dR7ZThFKt9v8E+YFh3nIrCKkEWi7R06cvv9ki8PoCXubqOQOKZ1EKnwCF4 J1yg== 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=WAaUVMJZwNldvM6e6aFGn3ObvVWSf2L0v/SEyFHK/I4=; b=knnzT7YCcWgXGxoByOu6bnAnlHJ0gKW7m80V8ytSRkQXmjKU9uI1cT2LcsTmgjwzxr UpAq/kBoeMCYr/c0F721DejmWKcp+/az0WH7kfzQuXs2gFAyISsg2vXVTtpgYn/V0Zcm yG7F4/Hw1pzrj2sJ4DEkyn8t0YENsx/txY7g9JBL5rhDefR1d25J2p1Z/jTSxWETNj9r OQiL4B5BT5GHMl6t1R5IY80DMNcULxjSXeO86akO2gu/RGOC60DbYas8BunQ1xaJl0mP ZOHIRULoWQ+092xw+eICo2hR9hZuD7ERmbalseMcgyuudWLUbHmAakPw23RCBn2lOGm3 gGfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=ltqQnT0E; 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 i14-20020a50870e000000b0045fc914660csi13336321edb.200.2022.11.16.12.54.43; Wed, 16 Nov 2022 12:55:06 -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=ltqQnT0E; 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 S234009AbiKPUyQ (ORCPT + 99 others); Wed, 16 Nov 2022 15:54:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234379AbiKPUxr (ORCPT ); Wed, 16 Nov 2022 15:53:47 -0500 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13B2DF25 for ; Wed, 16 Nov 2022 12:53:28 -0800 (PST) Received: by mail-ej1-x62a.google.com with SMTP id t25so47115074ejb.8 for ; Wed, 16 Nov 2022 12:53:28 -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=WAaUVMJZwNldvM6e6aFGn3ObvVWSf2L0v/SEyFHK/I4=; b=ltqQnT0EMFXwbpNbg9tdXI3avhCvHSr0oRUgU1tqw7+Unw0j+hl2GIavNu3ounoJDP nvNUC7Rd2dmnkcoByRgHQMhN2Jt4l1/KXgNv0sSJb+TiuAeuqfAnAJz5atJAXnGg99H8 UpdwG2F5AtucQXp6D8/Scz6aeCIdU8MXHn8EVGBz5ESYLLQRzTAbbP/gp6ksMxMJbCts Gs6tbhKZub13E96iZdU3qWuiP2WpqlcvYHSxlnDAJkidA4ULgmmj2hDHWbdq79H5FxsM g7iR8wYul79Lf08h1AekXk82Zcmmsk6LgHF6aSPOCqsOPbaSii3ag97VLOF4Qql2/YYp uN1A== 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=WAaUVMJZwNldvM6e6aFGn3ObvVWSf2L0v/SEyFHK/I4=; b=4Hj8FQgeoP6aly7cUz2CQd8ahT7sl6aqUbXIXmrHMp5JXllP6lGvqLLB1csBJ2ju91 0p9r3YaMSmJsks7KnlGz9ADiTr210vj+6TGIorj/IfC0+LdPFL1qQUuQ32hcXPFBE7Vu 7qq7CsSnlj9B96Dg3Z1XqjOdch9W9NC1UcZaz4DD4tSZdItZ6pVF11LROuPtfPPX3e2q J2rqRwCZjl9ZYUn2HNeVpw2iZRNUGiWmz8hZWwxx3DwcEnfTxqw9bogpldxiGCSV1JYR u2tUBUzinqFwsxF4EfNNf6uEcQiMI2MSpEK2r/vQxOeL3T0JuuTTNKnpjS7tfjo3VPPM 5udA== X-Gm-Message-State: ANoB5pmU/pLG/1lSqd5HQMJ/VQfjnGoJ5RI/tMxyXEuk2ViyXYep6sz/ kjwYvB/34Rn+6y7XeSVCLTBFQA== X-Received: by 2002:a17:906:33da:b0:78d:b046:aaae with SMTP id w26-20020a17090633da00b0078db046aaaemr18417533eja.218.1668632007251; Wed, 16 Nov 2022 12:53:27 -0800 (PST) Received: from blmsp.fritz.box ([2001:4090:a244:804b:353b:565:addf:3aa7]) by smtp.gmail.com with ESMTPSA id kv17-20020a17090778d100b007aece68483csm6782828ejc.193.2022.11.16.12.53.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 12:53:26 -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 04/15] can: m_can: Use transmit event FIFO watermark level interrupt Date: Wed, 16 Nov 2022 21:52:57 +0100 Message-Id: <20221116205308.2996556-5-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221116205308.2996556-1-msp@baylibre.com> References: <20221116205308.2996556-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?1749687579619873903?= X-GMAIL-MSGID: =?utf-8?q?1749687579619873903?= Currently the only mode of operation is an interrupt for every transmit event. This is inefficient for peripheral chips. Use the transmit FIFO event watermark interrupt instead if the FIFO size is more than 2. Use FIFOsize - 1 for the watermark so the interrupt is triggered early enough to not stop transmitting. Note that if the number of transmits is less than the watermark level, the transmit events will not be processed until there is any other interrupt. This will only affect statistic counters. Also there is an interrupt every time the timestamp wraps around. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index f5bba848bd56..4a6972c8bacd 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -254,6 +254,7 @@ enum m_can_reg { #define TXESC_TBDS_64B 0x7 /* Tx Event FIFO Configuration (TXEFC) */ +#define TXEFC_EFWM_MASK GENMASK(29, 24) #define TXEFC_EFS_MASK GENMASK(21, 16) /* Tx Event FIFO Status (TXEFS) */ @@ -1094,8 +1095,8 @@ static irqreturn_t m_can_isr(int irq, void *dev_id) netif_wake_queue(dev); } } else { - if (ir & IR_TEFN) { - /* New TX FIFO Element arrived */ + if (ir & (IR_TEFN | IR_TEFW)) { + /* New TX FIFO Element arrived or watermark reached */ if (m_can_echo_tx_event(dev) != 0) goto out_fail; if (!cdev->tx_skb && netif_queue_stopped(dev)) @@ -1242,6 +1243,7 @@ static void m_can_chip_config(struct net_device *dev) { struct m_can_classdev *cdev = netdev_priv(dev); u32 cccr, test; + u32 interrupts = IR_ALL_INT; m_can_config_endisable(cdev, true); @@ -1276,11 +1278,20 @@ static void m_can_chip_config(struct net_device *dev) FIELD_PREP(TXEFC_EFS_MASK, 1) | cdev->mcfg[MRAM_TXE].off); } else { + u32 txe_watermark; + + txe_watermark = cdev->mcfg[MRAM_TXE].num - 1; /* Full TX Event FIFO is used */ m_can_write(cdev, M_CAN_TXEFC, + FIELD_PREP(TXEFC_EFWM_MASK, + txe_watermark) | FIELD_PREP(TXEFC_EFS_MASK, cdev->mcfg[MRAM_TXE].num) | cdev->mcfg[MRAM_TXE].off); + + /* Watermark interrupt mode */ + if (txe_watermark) + interrupts &= ~IR_TEFN; } /* rx fifo configuration, blocking mode, fifo size 1 */ @@ -1338,15 +1349,13 @@ static void m_can_chip_config(struct net_device *dev) /* Enable interrupts */ m_can_write(cdev, M_CAN_IR, IR_ALL_INT); - if (!(cdev->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)) + if (!(cdev->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)) { if (cdev->version == 30) - m_can_write(cdev, M_CAN_IE, IR_ALL_INT & - ~(IR_ERR_LEC_30X)); + interrupts &= ~(IR_ERR_LEC_30X); else - m_can_write(cdev, M_CAN_IE, IR_ALL_INT & - ~(IR_ERR_LEC_31X)); - else - m_can_write(cdev, M_CAN_IE, IR_ALL_INT); + interrupts &= ~(IR_ERR_LEC_31X); + } + m_can_write(cdev, M_CAN_IE, interrupts); /* route all interrupts to INT0 */ m_can_write(cdev, M_CAN_ILS, ILS_ALL_INT0); From patchwork Wed Nov 16 20:52:58 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: 21266 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp57347wrr; Wed, 16 Nov 2022 12:56:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf6wFQwgookFM2Vk4DzkrJayhliA/FM/m7jwvesD63Nl05mstKXJppinkPnCLLWUKT30gplm X-Received: by 2002:a63:fd07:0:b0:46f:c9e8:5752 with SMTP id d7-20020a63fd07000000b0046fc9e85752mr22338312pgh.157.1668632218371; Wed, 16 Nov 2022 12:56:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668632218; cv=none; d=google.com; s=arc-20160816; b=KOTpbmDVD/UPqHfHxzDRF4lYPiqGiMMykSanT2ucsOmtRb3MOUJTuTmdwQjM3I70mo siAKBnoLepHfKOIh7zOkfv0yFit8BYHWsVyU/iUdaOAdZJUlDKeipB+lvOI43yUCYCav vOlqLTeABIaBPy2ZCP7YznmJHDYWq2LfEEcbdkNszycb5Uyk3Knmw+A8qkklxJ1BYFmj TSnqWPxsV3zWTselIXnQI2Vj0yTrB7/vwA1Ax5aZUtFHiSWk4yFuyFLKa6ymdSeDxM2s D8twQnfKQXqbpGbth8xpfgLpIznR0tQokj67UPL0ciKLUKYucbvE6HUsKyX61b4J1Tn3 JhJg== 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=BQXrupsqnXF1GGI8XYdR6EHbywjzNEqXAWKw2mVWyKY=; b=GVk1qhV2eqXTezAzaeImHuXkdcmOzYd/mozUfpgnUaxVEzFa/+VMgQ/UreMH/asvmq abPrjLYChFfAvRTwEPLBSpoUJSgKL06QZeSyvUxugg688qmbz7QliNz2Pgdg1U5N113U f2t0F6wDV5DLkXYb/YNYUQaRXHnP/MG+vZE3mWBSUD3s57RjjTZxbsyPFXfPfQoIAVVe xWKs9yyoFh9rM8G0GGaMvGuMVF/77UEnGiJAwGt3pz8aUATc8/J5hMD8bah2MUilU35o sm4UhShU7zW+ceo25htydLs6UZlVxjuo5YGfvZZZcXpGLQVIemnADS9To/CIdKgYwSg/ iPTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=q6Ppqc7S; 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 s4-20020a170903214400b0016c44b7c8c5si14137798ple.11.2022.11.16.12.56.45; Wed, 16 Nov 2022 12:56:58 -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=q6Ppqc7S; 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 S238946AbiKPUy3 (ORCPT + 99 others); Wed, 16 Nov 2022 15:54:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234611AbiKPUxt (ORCPT ); Wed, 16 Nov 2022 15:53:49 -0500 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2634C100A for ; Wed, 16 Nov 2022 12:53:29 -0800 (PST) Received: by mail-ed1-x52b.google.com with SMTP id l11so28489119edb.4 for ; Wed, 16 Nov 2022 12:53:29 -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=BQXrupsqnXF1GGI8XYdR6EHbywjzNEqXAWKw2mVWyKY=; b=q6Ppqc7SSiseRXuaUY5yOxkTlGSSXo+V1jekORDzSlvpc7FVSJiS4J/298QhA6gdjz vllNwMANVlC7mUEyI6DwHdG1EIQcbLUHu8+sCxeBC88/elFeyA3RCS5myrLVCzYGEHZH Tm51noOoIWVfOpl6H2VJVvINlzEJym4Ylb6cGFyjNQTWH0LG/UZ1ekr0gvJSEBocVGh9 HVA54xdOtt3L38zbcxMcKE5GmXopQXvkuNnNbmo5qezOs9EL8tfBMo0rAZZTlPDMp8ki aajesdEQKHBEdXLWnFidRTIhS4+QWm/ROAS/g9dp9zJSKjRuJqBCOOXEdTW+08lGpVy4 gA7A== 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=BQXrupsqnXF1GGI8XYdR6EHbywjzNEqXAWKw2mVWyKY=; b=oxyT+F2UAHyaVRt8gJvQZ/dNRlvejxFcALVbkH2k1db5bz1+mZOrGGVwmOG0yUFkhe lX8aX7D5Q2JXYPVDKSHP6Eu9ysC5u8lZS8nxp73+i3r/L9UQ/HyPBtIMGFs32Av9cTHl Xkd6n50YgGZwSdvQA0DXEmw4uXY2kSCyFOGCUDZ0XAIKDJbQWetfiLVzi6jDDrGCcN+b wMwUxogcE6N2fOW70hucbGBLdV5/+edHwIz0Y/r0uJE3jxkSSLYAizG+eyehwqjy3Cc/ xGZnFJzrDOM0eIjQqbn42ubkVr5rZVcP36FItG5P66mqPvIuyc+okMWzwffCvYMjsrdo nbow== X-Gm-Message-State: ANoB5pnQWK6hSgkvNqCYz9gAnQCpBb6ToPUtmjDjOG4hWTKQs3TyTJIb ScDLuyQMnIzoUQgnOtj9cLOmjQ== X-Received: by 2002:a05:6402:2906:b0:461:c7bd:7da3 with SMTP id ee6-20020a056402290600b00461c7bd7da3mr21102534edb.218.1668632008075; Wed, 16 Nov 2022 12:53:28 -0800 (PST) Received: from blmsp.fritz.box ([2001:4090:a244:804b:353b:565:addf:3aa7]) by smtp.gmail.com with ESMTPSA id kv17-20020a17090778d100b007aece68483csm6782828ejc.193.2022.11.16.12.53.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 12:53:27 -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 05/15] can: m_can: Disable unused interrupts Date: Wed, 16 Nov 2022 21:52:58 +0100 Message-Id: <20221116205308.2996556-6-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221116205308.2996556-1-msp@baylibre.com> References: <20221116205308.2996556-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?1749687697048906557?= X-GMAIL-MSGID: =?utf-8?q?1749687697048906557?= There are a number of interrupts that are not used by the driver at the moment. Disable all of these. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 4a6972c8bacd..5c00c6162058 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1245,6 +1245,11 @@ static void m_can_chip_config(struct net_device *dev) u32 cccr, test; u32 interrupts = IR_ALL_INT; + /* Disable unused interrupts */ + interrupts &= ~(IR_ARA | IR_ELO | IR_DRX | IR_TEFF | IR_TFE | IR_TCF | + IR_HPM | IR_RF1F | IR_RF1W | IR_RF1N | IR_RF0F | + IR_RF0W); + m_can_config_endisable(cdev, true); /* RX Buffer/FIFO Element Size 64 bytes data field */ From patchwork Wed Nov 16 20:52:59 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: 21262 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp56994wrr; Wed, 16 Nov 2022 12:55:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf56VRbxRoJE6gx9kS7CANVkqn/Z5+i6+FTgrJLpwY8DFEZHKSgwzuIoVbnmG/AbsSnsT4mD X-Received: by 2002:a17:902:e546:b0:188:4ea8:a685 with SMTP id n6-20020a170902e54600b001884ea8a685mr10706123plf.71.1668632139823; Wed, 16 Nov 2022 12:55:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668632139; cv=none; d=google.com; s=arc-20160816; b=r+YgcGwBw+ribyzGCJIlftDDb2QLldf4tPbRxDewQ+akbDta511+lwgwY0UI4UKd/i x8Rw/b46Jgzxs25aOR/2+REBcoNk6nQez3vp7slIXSwWRDLezSN7ZZD4+DDM9rw3VdNX e04GGd24x/qzZB/2JMK2urU8z0ACWatUq2mBHV+SkmEtYI1R3B8yn6PoFAwz+GRMov1f y6KIqlFsD8x7hUa0FQkF9UKJU7u/k6DnFCuX2B9pK9ycz6jI6uqGyNCDr4ikoxkSRZII 1GuxuwnP4X81bw+ZvGBVetuIFe5k38GRcLAAPrFfP5SqMGVpHmS59ImfM0lYkiNK9weN +bvA== 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=bbjKmVvFBDrESxHm1md/sljGuNuz1laUujygzg6feGk=; b=IsGU9uA2QkQx1ezo2KZ0XNg0DyGTQKwvGg2k04z/OKRkM+j8u+JIFSpyEMaI+DSXx/ 9K0rxiM2Z6wiFzAZk63L8Ab4guHGcaIWVR1J71k/WIplL+ZmcIbh2dzqrmyS7JB+cUIr MluBM167eQLuch68YgQm0vVp6WScqpwYNlvJlNbAeHYa1FICJsokzM2iTVx0hWNSt6m2 iQzgIpogTcaQZ0j7vErmtGpoUVobqyhWZ0S8rwh2ug3NKIJD8MSO2sj6UTFuTXtYokhl jShPZbq/S5bk8ePBa5/vuiiGHdKQ/YX+81uiY2GUqGuUmqGsCvTIyvPI8u56w2sLnhLr rj+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b="B/KjXbxQ"; 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 j18-20020a170902da9200b00178b95aa01fsi17768729plx.614.2022.11.16.12.55.26; Wed, 16 Nov 2022 12:55:39 -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="B/KjXbxQ"; 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 S238962AbiKPUyd (ORCPT + 99 others); Wed, 16 Nov 2022 15:54:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234622AbiKPUxu (ORCPT ); Wed, 16 Nov 2022 15:53:50 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCDE1115C for ; Wed, 16 Nov 2022 12:53:30 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id n12so47099760eja.11 for ; Wed, 16 Nov 2022 12:53:30 -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=bbjKmVvFBDrESxHm1md/sljGuNuz1laUujygzg6feGk=; b=B/KjXbxQuT9Gao+aqZROklxkKnU1p+JXxNuxzuhCtYHY1qTn69DbzDH9lQBT/eNtGu 4cvQiebMBzu2VeLwimrApbHF9QayhwvoyCWlOCRBn8/pI5cMT9/jVYr9FdPjS78n3BFG L1pif1BFc5E4V2kPh8B84h3XUMsGCRsYm5dOaNMhyLQo4J0WKRh/DlSE7T/JBJrD1n0z vvHzwckjHAiqraXNKoeG3vhOgwbAclMQU49UtaQb6AJAR6UYGVjv7SWDu6CwlttxVwQi VRcCrCalM2c6S0NuQeiqn9hJGg01DtEbjpSdHH1RqkJRZOnR6GXu/3esQC8fI16aIqDe Z6pg== 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=bbjKmVvFBDrESxHm1md/sljGuNuz1laUujygzg6feGk=; b=hTJMufPkGexfBONhLSl0r2ue0fwo1x2lo/43MXd/JdG2mSRDdZJ3JBVWKGQZFNMiP/ yIrBH659enRMb3tuBMbhA+WGGtTjiijcYuDzX39nhMLmyVohnkUIf/eLFJ0vygEhIj0A 4OMglAkA/XsbwQ4itwmfufNOvR73f2FM5ZgEq2WbHQChwOdIpKXyKrRPAuW46OUsx8rn wWFShQdHMvdqQST7E69bMlgbr8rTDyECGMgymSOeiX4IYaGd580ANjSWFukCT6n0928h P/Gf4jbBax05Fb2WNe1GqFJUzXEmOusXjBxXpKm8UmLCyWKXGFTZvFTpAs1CdsPI+V+y S+GA== X-Gm-Message-State: ANoB5pnCqUrSqwrYkeGcOThoM0v0Z20FRSJatN3IRi+IcoQpapLA++yJ O338rHtiLR85JdSkvPQtPCciIA== X-Received: by 2002:a17:906:141b:b0:78d:5176:c4d2 with SMTP id p27-20020a170906141b00b0078d5176c4d2mr18738240ejc.532.1668632008850; Wed, 16 Nov 2022 12:53:28 -0800 (PST) Received: from blmsp.fritz.box ([2001:4090:a244:804b:353b:565:addf:3aa7]) by smtp.gmail.com with ESMTPSA id kv17-20020a17090778d100b007aece68483csm6782828ejc.193.2022.11.16.12.53.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 12:53:28 -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 06/15] can: m_can: Avoid reading irqstatus twice Date: Wed, 16 Nov 2022 21:52:59 +0100 Message-Id: <20221116205308.2996556-7-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221116205308.2996556-1-msp@baylibre.com> References: <20221116205308.2996556-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?1749687614777875541?= X-GMAIL-MSGID: =?utf-8?q?1749687614777875541?= For peripheral devices the m_can_rx_handler is called directly after setting cdev->irqstatus. This means we don't have to read the irqstatus again in m_can_rx_handler. Avoid this by adding a parameter that is false for direct calls. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 5c00c6162058..0efa6dee0617 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -896,14 +896,13 @@ static int m_can_handle_bus_errors(struct net_device *dev, u32 irqstatus, return work_done; } -static int m_can_rx_handler(struct net_device *dev, int quota) +static int m_can_rx_handler(struct net_device *dev, int quota, u32 irqstatus) { struct m_can_classdev *cdev = netdev_priv(dev); int rx_work_or_err; int work_done = 0; - u32 irqstatus, psr; + u32 psr; - irqstatus = cdev->irqstatus | m_can_read(cdev, M_CAN_IR); if (!irqstatus) goto end; @@ -947,12 +946,12 @@ static int m_can_rx_handler(struct net_device *dev, int quota) return work_done; } -static int m_can_rx_peripheral(struct net_device *dev) +static int m_can_rx_peripheral(struct net_device *dev, u32 irqstatus) { struct m_can_classdev *cdev = netdev_priv(dev); int work_done; - work_done = m_can_rx_handler(dev, NAPI_POLL_WEIGHT); + work_done = m_can_rx_handler(dev, NAPI_POLL_WEIGHT, irqstatus); /* Don't re-enable interrupts if the driver had a fatal error * (e.g., FIFO read failure). @@ -968,8 +967,11 @@ static int m_can_poll(struct napi_struct *napi, int quota) struct net_device *dev = napi->dev; struct m_can_classdev *cdev = netdev_priv(dev); int work_done; + u32 irqstatus; + + irqstatus = cdev->irqstatus | m_can_read(cdev, M_CAN_IR); - work_done = m_can_rx_handler(dev, quota); + work_done = m_can_rx_handler(dev, quota, irqstatus); /* Don't re-enable interrupts if the driver had a fatal error * (e.g., FIFO read failure). @@ -1080,7 +1082,7 @@ static irqreturn_t m_can_isr(int irq, void *dev_id) m_can_disable_all_interrupts(cdev); if (!cdev->is_peripheral) napi_schedule(&cdev->napi); - else if (m_can_rx_peripheral(dev) < 0) + else if (m_can_rx_peripheral(dev, ir) < 0) goto out_fail; } From patchwork Wed Nov 16 20:53:00 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: 21263 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp57000wrr; Wed, 16 Nov 2022 12:55:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf5UnXSmTcV7BeT9UumdHxrzJvlM9tz8zZyfnd0UpQTb0E4tLNByk4I8/R3qNhtuNc+qcB+y X-Received: by 2002:a17:902:f304:b0:188:547d:b142 with SMTP id c4-20020a170902f30400b00188547db142mr10770921ple.103.1668632140867; Wed, 16 Nov 2022 12:55:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668632140; cv=none; d=google.com; s=arc-20160816; b=Epqru3G6azrgDgS6VSFjmLCtOaNcKU2e7vXf5pKygBHrV1rvBMCN+zLkhvonaTi+sx PZ34e7U91GR7or6SaanWQgvvU2b0GZUWE5YU3jet8cRhnJTNEEqcJRn/oR2/cYSCjTmI lK/JVLUtRMSXjvCC2y6F3HpL41tuHI/30zJAbp2PkaI27XVU558lnkEnFxs5svomi00c ajatJOBNRscyheyVZvtDXth4iL8DR70zi+3D7K3Crn67heCU8U+2CgxVO6cJgJgnq8/x cOeh3NOX/uc1UbXrbW04Qk32xe8Q03zHEkv/Gah+/QtnYrUWDZwTighvAw5MR7VQx8yF BIvg== 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=qMp0tWmayQFDCuQozvTUDpU6JW1zD9b9gmw4AkF62cg=; b=eIMuBJVwtVfMfFCUv6Cxh0naRVo3YuFo1ZkpngwEFjpQBZZRjtJ+gVhEdfmW03eYXR Cssmh5S6dlRMt085c/xnTci08bTJzlqFlWZ1S6ggs/VUq9xHo1buDnoqMb2cF25aUboF jWF+sz4LvIZl2EJ718TRrXTFjPlrNNe6Ixsh3+Iexvx0RJMjYpH7GxRJtaOfRYbmNMcw GtJ0nYLTcsyICwDCY2JNXNvSQJWmXFIsq54HQONTHnI4DrL+iLVYLHDh3quNIDr2UmCJ 2jLwcsHIV1mcVwOxu5gAP2PzWQlTOvIHZvnwvNs8NRGePDP5TSn4zhwWRWKD9UU3Z8dy FYbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=DfeLSauo; 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 1-20020a631741000000b0046ec058379bsi16324384pgx.99.2022.11.16.12.55.28; Wed, 16 Nov 2022 12:55:40 -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=DfeLSauo; 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 S238095AbiKPUyi (ORCPT + 99 others); Wed, 16 Nov 2022 15:54:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234639AbiKPUxu (ORCPT ); Wed, 16 Nov 2022 15:53:50 -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 3DEBC26F6 for ; Wed, 16 Nov 2022 12:53:31 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id bj12so47076715ejb.13 for ; Wed, 16 Nov 2022 12:53:30 -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=qMp0tWmayQFDCuQozvTUDpU6JW1zD9b9gmw4AkF62cg=; b=DfeLSauoK/xGMIYKQS8dUtNF5Y18jC4Dz7wPaMBhY5Wz7+f37x4ilwFFQVnDpFTXSy RKqXurBocAzbyzMqPdiS6IFjDxXzj+E3RZZQepcFM0ml8inFXsUQmDvg0Hy2EsCOITDH JHZYC75OVUxxK1+3P2am1KYY0AVX41vaxmwed/okFMyJDFu0zoFRlpFGwsO6hKrIPbwS inW4U/bJrq78cR6BOJhNepOxNwuQ/Qzlt8apxkk1uMwSP5visMZepMGF+j0smMOFVL/n NTjVi45THe7cCOGS1X7kkLDZg9X3Ivh5BUibveo9ryklA21H8QR8Gt0Or4XILbIIvTJT 23jg== 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=qMp0tWmayQFDCuQozvTUDpU6JW1zD9b9gmw4AkF62cg=; b=fVLJ7ZIwwaDGE9XNG7ZgN/XDhpegPhS+zLbKU63FoXD2VS5sp6qcEWtVYxupU26UtD wH482xTjL8xHp2g5B3MXipLOoAFuytaYa/m/UEqRtGB8J+kqkIq5BxzTfK0Wi6PxWHp/ YClVCRUvoTRewjFiBfTJL7Ldxx9ulEBKPMyzoDpzKmtubWARjqlU9TVA/JdxSDKLbYuf F7lsAmEItCC7pBFztYhQdPdTn1n9qP/XLOhZ7MfcnTtA05WOk5NzSwU86Pupd1U7ikcD ZwdNzcrrS5mlQQ//cDbTVlcgDFQsqVOCRsq2eizaaMW1hAtRB55nNE7fojm7Vm3FTbvW 2MHg== X-Gm-Message-State: ANoB5plQ9K49PRId9PUeIBcE0oOhpx3v70tmNI/wetRONfeC72slgvjL 7P0K2E+zCjJIB01letWXMLWfsQ== X-Received: by 2002:a17:907:cc9d:b0:7ac:ef6b:1ef4 with SMTP id up29-20020a170907cc9d00b007acef6b1ef4mr20163923ejc.104.1668632009629; Wed, 16 Nov 2022 12:53:29 -0800 (PST) Received: from blmsp.fritz.box ([2001:4090:a244:804b:353b:565:addf:3aa7]) by smtp.gmail.com with ESMTPSA id kv17-20020a17090778d100b007aece68483csm6782828ejc.193.2022.11.16.12.53.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 12:53:29 -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 07/15] can: m_can: Read register PSR only on error Date: Wed, 16 Nov 2022 21:53:00 +0100 Message-Id: <20221116205308.2996556-8-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221116205308.2996556-1-msp@baylibre.com> References: <20221116205308.2996556-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?1749687616161158852?= X-GMAIL-MSGID: =?utf-8?q?1749687616161158852?= Only read register PSR if there is an error indicated in irqstatus. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 0efa6dee0617..1d15beaea920 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -901,7 +901,6 @@ static int m_can_rx_handler(struct net_device *dev, int quota, u32 irqstatus) struct m_can_classdev *cdev = netdev_priv(dev); int rx_work_or_err; int work_done = 0; - u32 psr; if (!irqstatus) goto end; @@ -927,13 +926,13 @@ static int m_can_rx_handler(struct net_device *dev, int quota, u32 irqstatus) } } - psr = m_can_read(cdev, M_CAN_PSR); - if (irqstatus & IR_ERR_STATE) - work_done += m_can_handle_state_errors(dev, psr); + work_done += m_can_handle_state_errors(dev, + m_can_read(cdev, M_CAN_PSR)); if (irqstatus & IR_ERR_BUS_30X) - work_done += m_can_handle_bus_errors(dev, irqstatus, psr); + work_done += m_can_handle_bus_errors(dev, irqstatus, + m_can_read(cdev, M_CAN_PSR)); if (irqstatus & IR_RF0N) { rx_work_or_err = m_can_do_rx_poll(dev, (quota - work_done)); From patchwork Wed Nov 16 20:53:01 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: 21270 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp57619wrr; Wed, 16 Nov 2022 12:57:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf69686CSXXY44g5V7nXvYLflUzau+Hrnmesr+JhPoF/ggQxcehhscji9poCmdVNRf/RmCdr X-Received: by 2002:aa7:8e46:0:b0:56b:abf4:f77c with SMTP id d6-20020aa78e46000000b0056babf4f77cmr24844967pfr.37.1668632279254; Wed, 16 Nov 2022 12:57:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668632279; cv=none; d=google.com; s=arc-20160816; b=FdrnyMA2tQOimgUG7fsjiFV/Nt8TDCISOV87s6HDhd5kDs+dlVAYVwFf+B3JeYb47+ 64AFjn1CSd0+U6TECspVaV5VZtSW+/jCWb19wofVHJ85ZsbBjPH0i/SLDTXF8lNvPwuV SP2x3kg9psV/CRiO1/AarmnHzjkmaq7UpFhIS/UKQR8aARdXbycHQJFkDidyW1c367k3 KEL7VCgkini3T21PZql0yqEgXkQmWg4Wooef8ld2osMwpST7XmSSBLIXvCHivWhp48cf F4y2liFx2ux5SLcnhmmbfm8o/kR4BYdMbzKE/CU1aOCQlLEXlf+4LIv49YeC7AO5MCoQ /Gzw== 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=b1NW4yffam7J6Z66UeY98X/Lxzuu+uqNj1++GX3J7z0=; b=zIkS7flXVTjxZxiidoGIotonzb9pidfxqDAjpv329NImgNoUDbySbpVHV42GPoZfpR DBdLHrkqKKT2c0bMwE9uHg79x2ct301NfYD8O0l248/UrxL7ivKDLr3RGeL+Nkcx2Tjf hj8NFf+eFq/AEdoRz6jMyGyO8ynJb57n+dlGCDFhNwOhuRB5FIfkcbIPKgNWwyc2AEI7 CiFWpdmpXDaNWhVg/MQqhj4NgQUIDJISl32iM2dx9pwa62EHUXI2R49cKxJoMgkO4KOb Cfc5tWnu7V0Ui7A1oZAZMrQb9Dh8qTRMdiimXm1VIwGd1iNHeZomyEXp7Y/pfn3u8Gk7 XVQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=Fn+pjOi7; 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 t11-20020a170902d14b00b00174c5fdc8d2si14162631plt.307.2022.11.16.12.57.43; Wed, 16 Nov 2022 12:57:59 -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=Fn+pjOi7; 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 S239006AbiKPUyl (ORCPT + 99 others); Wed, 16 Nov 2022 15:54:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237515AbiKPUxw (ORCPT ); Wed, 16 Nov 2022 15:53:52 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B0856272 for ; Wed, 16 Nov 2022 12:53:31 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id n21so6410378ejb.9 for ; Wed, 16 Nov 2022 12:53:31 -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=b1NW4yffam7J6Z66UeY98X/Lxzuu+uqNj1++GX3J7z0=; b=Fn+pjOi7VxZlwBiOMmabPiR+6IHaFVnPkFKbMENKhdrwfdApvpUQBK2DrzSm8UZ3l+ LBgLnkruBLVK5H9Tz3LtB/DxxziqVAKGYdy+2KAVIJ3tPxXMTLxirF7JOIUcPu3bk1s5 Ah2GESoKw9t04qJclb9ZKouemoIya66kpstWZwAR76Ni2A6BXsyOjIau71qtKm2twGCH OZewz/IsWr1KR9xbm3owiIWYvu9j4qJ6AWvx6bzdTD0OK/RnbkqCeFRwpg88Birnm2FI IBOaNk32rlVnzjgJDp+VA4edjSpYwHv/Iw52HlvRGfnLV14A4FTa8v7sbR1UtkAAbsVg JDqw== 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=b1NW4yffam7J6Z66UeY98X/Lxzuu+uqNj1++GX3J7z0=; b=4iQk7Pht3Mz38WKvyoPfJKAmO8CndG4atdxm/AzKNKdXmEw9JDomUUFyoAMqtKmiNO kAZERBT8ftsoMZ1CXBG32533AKnu0rfc4ug3C6+TJfUkye+cIirneQjffMsuyVjyq2BQ 9JUX0ySMGN9U4Peq9LrzWFVPQj2sEnEtvRDOgb/8QkC8IiaPrO3DPoVfggJuuMrRiAt3 6Ws8eYz7xEA5Yi6mpGn2jlF/TVH9GCaFb2uDO6Drvzh/OFvWrXBCqJhUku+TW/tix0Ik RIXd7fd3NPVAAjiMBnsaYm0w4hT62dXfeuq7hzl5/7mxq7xXqvCi7/07iTvhSnqw088n fp5Q== X-Gm-Message-State: ANoB5pnvmeM0zshXq4byabEsn5VsP/uulPvDm7O333cMPEVtnyH1ghYS FB6mF/+vO1/qeDzYNLRAjLMZlA== X-Received: by 2002:a17:906:489a:b0:7b2:73d0:4b9c with SMTP id v26-20020a170906489a00b007b273d04b9cmr6681647ejq.746.1668632010464; Wed, 16 Nov 2022 12:53:30 -0800 (PST) Received: from blmsp.fritz.box ([2001:4090:a244:804b:353b:565:addf:3aa7]) by smtp.gmail.com with ESMTPSA id kv17-20020a17090778d100b007aece68483csm6782828ejc.193.2022.11.16.12.53.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 12:53:30 -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 08/15] can: m_can: Count TXE FIFO getidx in the driver Date: Wed, 16 Nov 2022 21:53:01 +0100 Message-Id: <20221116205308.2996556-9-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221116205308.2996556-1-msp@baylibre.com> References: <20221116205308.2996556-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?1749687761142142576?= X-GMAIL-MSGID: =?utf-8?q?1749687761142142576?= 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 1d15beaea920..27095a7254dd 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1021,15 +1021,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) { @@ -1043,6 +1041,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); --cdev->tx_fifo_in_flight; /* update stats */ From patchwork Wed Nov 16 20:53:02 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: 21271 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp57727wrr; Wed, 16 Nov 2022 12:58:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf50p43OCAAmSezDHl66klGRzW2Iqd7tld8Gbt23KzPBCwsTvhWZsMY+xCpGT8gyDUUVFvdj X-Received: by 2002:a17:902:7616:b0:188:b943:2e1c with SMTP id k22-20020a170902761600b00188b9432e1cmr10633734pll.43.1668632299372; Wed, 16 Nov 2022 12:58:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668632299; cv=none; d=google.com; s=arc-20160816; b=BrwnWk4YdgupGdOTn7MDmcBFXhRqoLseJpT2WW5gZD+ZJqS2maQeOJIvVm3mp7AVDb aMJIHLpG1PNumdr6ivLD8yexhlVrMiIqNpgDRcE5Z5ljMhqMs6ViShwNsey1Qq1a7CON RDF5Q5DtE8oilQhzPmjkRxT8ZZdIqNoHXmabhVJ1O2mAc6nQNo6crc49faJ5vIby1cCe iaM5rr+tVeVK3VufikVPOrnTOc6OP+TnzoGsFQ64vQPLgNw9Ffd5CYTdDQLI9jMq84q6 AqEcU39PhQEYZZ5y+1qC2CRTJ17ID7aXI5gAmCLyJBgYjTOxBOFIY+uA0k96xQ3Spiea FioA== 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=76EqNlpDreQF4PZmggfgrCfKC4hAP4lphiWDRZe7nMM=; b=fCf5PP54YEIDo8RBsQASJwvA1KRIdxr8/Rsp4wkxRzsFFL7gpGzluOa6v+nty8eWp/ upKO+nqeb+PBZSVztJ4BJeWKCJAmY5kskMKGtw6mKz0J3hVDCzNrxDXD8ewI4MDx5ppN miry/M8fyIHzQA1pQ1AXyXXhUZzx5GcurxpN+KZFIEOXULwm+EYmgBGAbqbEbrZiacgi 0HyAvHTjOiSMEJTNZLwbM2AFjMrD/v8CqfkSf0MxU7zj6x1xaC+L26EwH1YEgFSafIuz h1cStXjFd89i5ni9Wf2m64+S83TuuUV9tl2pLTDNO5mgiNCp/U7IyQnusvYxm/fKuHNB 2cwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b="uqThAUy/"; 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 z3-20020a170903018300b0017f641cac01si18869714plg.27.2022.11.16.12.58.06; Wed, 16 Nov 2022 12:58:19 -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="uqThAUy/"; 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 S239031AbiKPUyu (ORCPT + 99 others); Wed, 16 Nov 2022 15:54:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238294AbiKPUx4 (ORCPT ); Wed, 16 Nov 2022 15:53:56 -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 D53C26418 for ; Wed, 16 Nov 2022 12:53:32 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id ft34so47068991ejc.12 for ; Wed, 16 Nov 2022 12:53:32 -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=76EqNlpDreQF4PZmggfgrCfKC4hAP4lphiWDRZe7nMM=; b=uqThAUy/RKwtT1RRbAu8P5FOVTNwBorxorshelO+Gn57d4TcNitGks2jHG8VjQaJT5 TEavYIJSpNPGFpNDMMxKMRiDVcrerBSpI03qY1cHLpu4Pp4zoLW6+xH9aWJwIFdnkCAX 0ETvxF2Apny/2uqVTtLgkjN2UIHwXAqRhbGiOYQJD4Eb3rAUT61h0518k/ei4UTZiryA i2YbNLFvgObJVuHDg/QVg4DSJn1XczUQoYspgCNo6+FTr1x0glc82I6g7nZo6e/KVk/A 1qoiG9heuHqcuR4buQqWP6K0bkU2ZNU7Tn+yhL1XqlnQWFTTdgdp0FlqnVi6oiegV22Y tuJw== 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=76EqNlpDreQF4PZmggfgrCfKC4hAP4lphiWDRZe7nMM=; b=xFw7cVZ3OqW29N2pAWLMATtjcG+rjne+MxjX53leGhn2xXOQrIfJhJpRPVIVy24ISa x3U4Z4M67kn2GtBQowFza5XwXwqlE3qD0fXC+LF/HVnY+KhdcC4El5a5vsqTYfHDhTn1 foW4ADjdtO+wakwIn9woFnWwle8dc8euAAVfDLLH5CKxeJS//EEXLlntewZNg9HsDTWF HCJYIb9WDuK/S30XL+/w3wojc/jHJnSC0ZfIw6kLN8T97b2b7D4Uh/qTLQDYeB7elyC3 9Ex1ArYVltDI39x9FrRxzGKCq7yDktl1/CDjbT7thLv9dv6VExaFV043O7ddUEtsSAhn gUuw== X-Gm-Message-State: ANoB5pl/9QLVk5ZfUw6ykDVP6PtjR0xcBhlbPzJOVQhFz/zHKCwoLAXS yW4U6NMulyimLsIYWQLlGFGbXQ== X-Received: by 2002:a17:906:2696:b0:7ae:4ed2:84f4 with SMTP id t22-20020a170906269600b007ae4ed284f4mr18752930ejc.429.1668632011225; Wed, 16 Nov 2022 12:53:31 -0800 (PST) Received: from blmsp.fritz.box ([2001:4090:a244:804b:353b:565:addf:3aa7]) by smtp.gmail.com with ESMTPSA id kv17-20020a17090778d100b007aece68483csm6782828ejc.193.2022.11.16.12.53.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 12:53:30 -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 09/15] can: m_can: Count read getindex in the driver Date: Wed, 16 Nov 2022 21:53:02 +0100 Message-Id: <20221116205308.2996556-10-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221116205308.2996556-1-msp@baylibre.com> References: <20221116205308.2996556-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?1749687782007392344?= X-GMAIL-MSGID: =?utf-8?q?1749687782007392344?= The getindex gets increased by one every time. We can calculate the correct getindex in the driver and avoid the additional reads of rxfs. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 27095a7254dd..02fd7fe4e9f8 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -477,19 +477,16 @@ static void m_can_receive_skb(struct m_can_classdev *cdev, } } -static int m_can_read_fifo(struct net_device *dev, u32 rxfs) +static int m_can_read_fifo(struct net_device *dev, u32 fgi) { struct net_device_stats *stats = &dev->stats; struct m_can_classdev *cdev = netdev_priv(dev); struct canfd_frame *cf; struct sk_buff *skb; struct id_and_dlc fifo_header; - u32 fgi; u32 timestamp = 0; int err; - /* calculate the fifo get index for where to read data */ - fgi = FIELD_GET(RXFS_FGI_MASK, rxfs); err = m_can_fifo_read(cdev, fgi, M_CAN_FIFO_ID, &fifo_header, 2); if (err) goto out_fail; @@ -554,6 +551,9 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota) struct m_can_classdev *cdev = netdev_priv(dev); u32 pkts = 0; u32 rxfs; + u32 rx_count; + u32 fgi; + int i; int err; rxfs = m_can_read(cdev, M_CAN_RXF0S); @@ -562,14 +562,17 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota) return 0; } - while ((rxfs & RXFS_FFL_MASK) && (quota > 0)) { - err = m_can_read_fifo(dev, rxfs); + rx_count = FIELD_GET(RXFS_FFL_MASK, rxfs); + fgi = FIELD_GET(RXFS_FGI_MASK, rxfs); + + for (i = 0; i < rx_count && quota > 0; ++i) { + err = m_can_read_fifo(dev, fgi); if (err) return err; quota--; pkts++; - rxfs = m_can_read(cdev, M_CAN_RXF0S); + fgi = (++fgi >= cdev->mcfg[MRAM_RXF0].num ? 0 : fgi); } return pkts; From patchwork Wed Nov 16 20:53:03 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: 21265 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp57281wrr; Wed, 16 Nov 2022 12:56:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf6sSN0ZDDlL45WnXWovjFwRnilOaaS8/QkJ5AUnVEHCyiIJb/nZxlIjmDeY1L/9qoBLfjWt X-Received: by 2002:aa7:8dc2:0:b0:56b:b520:3751 with SMTP id j2-20020aa78dc2000000b0056bb5203751mr24536287pfr.29.1668632204300; Wed, 16 Nov 2022 12:56:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668632204; cv=none; d=google.com; s=arc-20160816; b=t2JQXyc70yVE4YTYohUE21cNEaz/ciruq+doh0NOmf75fI4IudHFe67PPwdp904GfW tugmSytL8v7qIkFstfATFEYtAVGEtBprGmPgQjnPO2Y4Mx9Llntj6P0/dd3jN8j8ZpVW F760rSD/s6RjvW7k3FdMg0Go57BloYg25+JXsEPkHXOstNlZnb49H2v+ixkjFavRH1kh 4ikwNFWL2i9AnKrfVL3RAjr23mEYq3+V2UouaLMvJdXTokKGts+OaWYmXEFiU+qcoPYZ T4B+Gs8MeCfLbGtGvQCyUJI6KcTXnvwnwl1j0wtFSYki1BP0BhknUvUNdqYwJ8+Ft7aX jz9g== 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=35Qy5T8b8nZe0+fVvuZXlmUhh51OUfHfDykDW4uao6I=; b=obXLO0z0TwOtk3ocEG9QvPIxWxtpzgAjpuISrP2fLnDD6TKB13jt2Bjd4hlRPV+Xys /j11nKyxUJ7GSLi9RdjN4PiuDekzR7mBsFkI2H0cA7iWHQv/7znwbmZ+rY/VVRY3JfhF 5eUGgIE9Y+hdn2WGs2i2XX2ftX6mfFBt5UeA1ClKWdLw8C6uUAIUZuYifXzovsRwfg+O 0FUaOSN2s2p2mrZRk2TiQpgQgT5lFGi8a+D/nb62EVCGtMuvgWcX6Z4XqiEG0XyEVQkH p0+m6jDCoGbnjcWCLpqf9ezPiJEkB8bEqgJ94xx2wXExIXqmpCj4wu75Kjjg6xmMQZor UGeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=aNitAnr3; 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 v2-20020a632f02000000b0046edf48affcsi16755015pgv.399.2022.11.16.12.56.30; Wed, 16 Nov 2022 12:56:44 -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=aNitAnr3; 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 S238529AbiKPUyx (ORCPT + 99 others); Wed, 16 Nov 2022 15:54:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238422AbiKPUx4 (ORCPT ); Wed, 16 Nov 2022 15:53:56 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC12A6478 for ; Wed, 16 Nov 2022 12:53:33 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id n21so6410565ejb.9 for ; Wed, 16 Nov 2022 12:53:33 -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=35Qy5T8b8nZe0+fVvuZXlmUhh51OUfHfDykDW4uao6I=; b=aNitAnr3LnNKd7Q5VxgwDVTqryOo8InS88hIhNw4Tb7wa4GDJxed7sbIf24+anq4l9 q75Js/1GYwp0hJcvNZkTAhj8RGqxK412V4pEGKnVo/d+10Y3oqGoHdJUIIvtzJJQrHfr rBL2myiZiFe/ZOusjxXo/+EAVDyAIr+Mh2eiH8yCdDy88lcjpKV87JePE/ondWp2B0ev uIUFFxsd/up3e5nTvGwZeRIoR59QxqDO7kVLH1BcORpYporP5mYi/uxrVsvBGNUb05IV JYlrYmwHf6bBuWaI/zaH52ZZX0SxFLQYkg4ghpknehpiYMJ7rYplySv0WsZpTswEt2FG ilIw== 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=35Qy5T8b8nZe0+fVvuZXlmUhh51OUfHfDykDW4uao6I=; b=YZNagk9wnau6rsURTmMlmJnaEkRWJoYZhZRwrFJjBVBuGkO/wvqbZJRhLAD0ZIw0SU 6w72r/SBgbyHf7U9EW1Hl8pqX6yO7JHv8gE6HigpvvfeeA1h4twcRigo6CjZs5ucuf/s jwO63CA6D3xhPaRP8CrbooOVB73g0byy3jx6es1Tb0+mgWRYgxUGUhhgzHqrLN51G2Y5 gqOxkbOb8ZnzrrDsPsFL2xLiq8dhxjYqu3popCJuTzSVvn15eJf0PjsOvn01AcLCNYvU jhg7s7pwFTWgSSuvytLq4ePGr1dFTszPUkg1xOz0iXbMCHV5JVNGrMy2qLvmqEEfL32t mMqQ== X-Gm-Message-State: ANoB5pmlM5wCMX31rs3FO63OyE2OOStufy2J1oSdNvdwtaXafQRTJ3Wi xGYNPEnxIVdUrql7CIzfxqxZvw== X-Received: by 2002:a17:907:98b6:b0:7ad:c0ec:7ad4 with SMTP id ju22-20020a17090798b600b007adc0ec7ad4mr18535259ejc.585.1668632012051; Wed, 16 Nov 2022 12:53:32 -0800 (PST) Received: from blmsp.fritz.box ([2001:4090:a244:804b:353b:565:addf:3aa7]) by smtp.gmail.com with ESMTPSA id kv17-20020a17090778d100b007aece68483csm6782828ejc.193.2022.11.16.12.53.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 12:53:31 -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 10/15] can: m_can: Batch acknowledge rx fifo Date: Wed, 16 Nov 2022 21:53:03 +0100 Message-Id: <20221116205308.2996556-11-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221116205308.2996556-1-msp@baylibre.com> References: <20221116205308.2996556-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?1749687682759184889?= X-GMAIL-MSGID: =?utf-8?q?1749687682759184889?= Instead of acknowledging every item of the fifo, only acknowledge the last item read. This behavior is documented in the datasheet. The new getindex will be the acknowledged item + 1. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 02fd7fe4e9f8..6179b9e815ed 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -530,9 +530,6 @@ static int m_can_read_fifo(struct net_device *dev, u32 fgi) } stats->rx_packets++; - /* acknowledge rx fifo 0 */ - m_can_write(cdev, M_CAN_RXF0A, fgi); - timestamp = FIELD_GET(RX_BUF_RXTS_MASK, fifo_header.dlc) << 16; m_can_receive_skb(cdev, skb, timestamp); @@ -553,8 +550,9 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota) u32 rxfs; u32 rx_count; u32 fgi; + int ack_fgi = -1; int i; - int err; + int err = 0; rxfs = m_can_read(cdev, M_CAN_RXF0S); if (!(rxfs & RXFS_FFL_MASK)) { @@ -568,13 +566,20 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota) for (i = 0; i < rx_count && quota > 0; ++i) { err = m_can_read_fifo(dev, fgi); if (err) - return err; + break; quota--; pkts++; + ack_fgi = fgi; fgi = (++fgi >= cdev->mcfg[MRAM_RXF0].num ? 0 : fgi); } + if (ack_fgi != -1) + m_can_write(cdev, M_CAN_RXF0A, ack_fgi); + + if (err) + return err; + return pkts; } From patchwork Wed Nov 16 20:53:04 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: 21267 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp57507wrr; Wed, 16 Nov 2022 12:57:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf7ucRC45LURQcNpo3aCzbSmt/1WE+pOsONKYPk51RKJa67hE5DLLXwzfhtwaj72HQkp6uU9 X-Received: by 2002:a17:90a:19cb:b0:205:fa0b:798c with SMTP id 11-20020a17090a19cb00b00205fa0b798cmr5439289pjj.179.1668632253654; Wed, 16 Nov 2022 12:57:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668632253; cv=none; d=google.com; s=arc-20160816; b=LwcbbBRIaNVta0fJ2zn1PwGilPVCu0oZsTHGbUnyysuZfsCG8Acd8GSweEXsTc/Mzh IYCTbcqO1GjbyoK+NTNqh/DZLL7ij8YX0AulR/Ba5yskgyhYFBOSdYzpARBRD/aqZpMx x6eihnQYF6oZo3pyTiPrK7uvz+R8uxd+I/6ozJJXUWr4bZ+UUuGpL/G3HMyoVoFmYKMg TMXF/nviDd5MtxZIISS+iANcv5wuZn7wkzr8MB0kl9XlWXMWY9+ZKpY149v9HP7Oo8uh YFKAadVsSMBQ18QzKfiiVg/2+5lRTGc5YCls9mn6XWImbIlzIVyeyg+KzjkXo/mq4A4U vZJg== 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=63B61nbFxXevaqifM6unbv7DVTV+dONfI4xcJ7fYbEM=; b=g/3BQZnLQg/xmAfphrK4bpeDWzCZE9yBE9j2p8BIcgH6pGo+i0sIanbZGpoZWH59vb ua88QDX3S0mtMimerXt/sLbi9ra2gw3nKynru2DOdfN3pDJRJO7Bx6dg4r8SX9LhvfvU jP9nF+HKw5f1um1JrIM3f7xBrDIe276+JhdzTQMWs7P3qCQc4UfXn+peAH0fBHNFXVQv /BkZENANSomZPInbNTUx332CcTYzrzT2PebpsPYrBi6XuSlE7SsfclW1LWL0yKcJPqEx 4E6VMe+J5Bn6CPjKV8Beq+BIoz84laGPvkV7Z4ndfp7SeGl64zkM3OjEyQCKqQyeP7XP CiAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=XrxRLv0i; 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-20020a17090a948700b00200b014d2adsi2624204pjo.26.2022.11.16.12.57.21; Wed, 16 Nov 2022 12:57:33 -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=XrxRLv0i; 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 S239065AbiKPUy5 (ORCPT + 99 others); Wed, 16 Nov 2022 15:54:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233438AbiKPUx5 (ORCPT ); Wed, 16 Nov 2022 15:53:57 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B60666558 for ; Wed, 16 Nov 2022 12:53:34 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id bj12so47077093ejb.13 for ; Wed, 16 Nov 2022 12:53:34 -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=63B61nbFxXevaqifM6unbv7DVTV+dONfI4xcJ7fYbEM=; b=XrxRLv0ioHvztchOOEylzwIXG5E6/NOIFrU0lDh3B+0C0zkoUMrAFpJRw5jxDREGEQ p6GpjhDPZ5pODwZZUQtgNoFhFAbLTCrl+H6achFwFFRrd/Zy5aTWNvi3Gr5fB7kk2UtA AVAQLiexAir2XBwRfZHloDmCAlDgzVrEK8mSWP+Mox+pGSLt2NJnziGicFxo06eyvGwi +nvJE09r0HP94yDjezRuisu3bCGIabGRbmxdPasO5vG2NO4bfHB6Qo/YcTBQIx+PEVJR SS3NhGa6W/yb9shUV8lZ13ZLOL8QC4CeWXtYPE1BrDK4+jsh/TVT7EjGFDmbzbuwrwFD V7yA== 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=63B61nbFxXevaqifM6unbv7DVTV+dONfI4xcJ7fYbEM=; b=D69MOBMV5h4EzsExUu18yZiz8Cts/ZW7XHUopUiVDCM1fOjGLAMMIofi8IhBsaldrt CcxyVzJf8Vbo4NSxMnflOoN142HShsecF8uF5P/KRSqLwEbfIUKXbCccXqe6ORzviZwm mifGl/aUpiWIapgNPfY0NgHZ1Ily+EgCd/29SBPX+rMmKXgc7c3F4IszYrX7AT+g/JTR EcMnahmGi0NGSFYaFlSow8Z4t5AOc/loTpbuC+w0AbOJS4acATK0GnTrQsE5L2VMpoY+ 6dVkTErraZarfVADDiUs8G/Pz//k4++k05nmo4lEnkR98EUyCCpijF9shpRF4bhh6Rt4 OPXA== X-Gm-Message-State: ANoB5pmkvFUFYgH+zxOvTbGSHYHoyXauXvWbFBKKW8zu6td0PtUxt3JS Ko+nouDEnty84BkqwK5sbq2lRg== X-Received: by 2002:a17:907:2b26:b0:7ae:c460:c65f with SMTP id gc38-20020a1709072b2600b007aec460c65fmr18733831ejc.226.1668632012845; Wed, 16 Nov 2022 12:53:32 -0800 (PST) Received: from blmsp.fritz.box ([2001:4090:a244:804b:353b:565:addf:3aa7]) by smtp.gmail.com with ESMTPSA id kv17-20020a17090778d100b007aece68483csm6782828ejc.193.2022.11.16.12.53.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 12:53:32 -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 11/15] can: m_can: Batch acknowledge transmit events Date: Wed, 16 Nov 2022 21:53:04 +0100 Message-Id: <20221116205308.2996556-12-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221116205308.2996556-1-msp@baylibre.com> References: <20221116205308.2996556-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?1749687733921788322?= X-GMAIL-MSGID: =?utf-8?q?1749687733921788322?= 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 6179b9e815ed..347ba8e7d1b3 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1019,7 +1019,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); @@ -1034,21 +1036,18 @@ 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); --cdev->tx_fifo_in_flight; @@ -1056,7 +1055,11 @@ static int m_can_echo_tx_event(struct net_device *dev) 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) From patchwork Wed Nov 16 20:53:05 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: 21268 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp57521wrr; Wed, 16 Nov 2022 12:57:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf7/gF3q0fdCTYWpKVV2nMzjQTVz0MnlC3G6eMf6lFYcvAlQ1IAVEan0jSXuqc1Ophajb21E X-Received: by 2002:a17:902:e847:b0:186:8d12:f51f with SMTP id t7-20020a170902e84700b001868d12f51fmr10767211plg.129.1668632256207; Wed, 16 Nov 2022 12:57:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668632256; cv=none; d=google.com; s=arc-20160816; b=rUscsl8lN0PE68ReC3nWTJah3niDwVbEuiifJHTqi3O86YO90AeRCJH4fjwd2aqmDK B1JGt2g3BdJAELiRLEUI2MwEs+bmddaocP7V3R7Pqm19dq2fdgm4tQWyLv7PpF09spaq gn8zkyJoaxDLsjZUXb61x2UQd50evg/LVPE9v3kwRerKWwippQ3oqYHlT8PidKLSqFKM BOQbkZcu9xf5+QurVjbrNRG/y58Q4efsNcjGS9Es/x6FHs3c2vWDj/uEe8VLrEoYOfn0 whmYh8J75H8DBvLMMvmATHxXNabF2jwyih9A1I6V9f5k8e+nbtGkPDaiECJzvsfDiDJQ smcw== 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=ah82tTOOObOFB3MDfuIM4J36KFmptfShWyxBMhuP5Xo=; b=aErgHBVIZIgmIpxJJU+8iB+Qc1HJV+nbl6JRovFcjU1tygBK2mEi+UK4zX42QPghdR 7Ocrym+bZyjd0S2qgJ3n9R2fg3PVrmdBHIGSwtSjjzzXxz+z7vMhCYStBxcwTZQfLauU RGUPjtPmdUxrsJfwSnZOrE15Z7F+fkdEIBpksmVMpL87zdJ6hpxtBj2cFBojhpErFRvX 47plAwcqWuXYt6wd4h2BJEySz5J0O2aHIP80dufzpcJPmJen6BJVYzJb7I3dg9jQQP/E +g6ineJad6/pf7hohMv4mMURj5jOOryiqkD2ZWsUy3RI0Mdja0aGEoe4DAWOcJsDXr/e c0/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=FuFd7KEQ; 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 n21-20020aa78a55000000b0056ec4a6babasi13909411pfa.381.2022.11.16.12.57.23; Wed, 16 Nov 2022 12:57:36 -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=FuFd7KEQ; 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 S239074AbiKPUzA (ORCPT + 99 others); Wed, 16 Nov 2022 15:55:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238534AbiKPUx5 (ORCPT ); Wed, 16 Nov 2022 15:53:57 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26F366546 for ; Wed, 16 Nov 2022 12:53:34 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id n20so99547ejh.0 for ; Wed, 16 Nov 2022 12:53:33 -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=ah82tTOOObOFB3MDfuIM4J36KFmptfShWyxBMhuP5Xo=; b=FuFd7KEQ6d41KZBOZhhpBhnMjYXdxKD3gEK+faGWa/XfhW2EFx9CCnj4pbSYMac2Rg VIuXojA8qB/pnTAwSH/PmZxKpCmL2eAkLQyhE5BR42zG3IEDpWTJHKhUoMPbBlM0cwsa aoDXSsa8MbXs5ScTvpr0crbR+Zr5r66T3BoltNI3RObZ5w0EZWcatVi6Jt5ZsATEp/Dw jt8b+Zt2tr8/FhtYKWD6X46XX4b1PFmxtCddxq2uisW6m40miJnZawPupYuP4ofRL7OM qqYATmJca9f9feYgFHce3A/dYWupesj+8yaW4A7p+R4+b/3M0R4QMymOG5zlpIyc1L2s gTUQ== 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=ah82tTOOObOFB3MDfuIM4J36KFmptfShWyxBMhuP5Xo=; b=jYylEn3XdlXg9e2zO4B7Dp4X2LqHlFos6Cq53QRkalDXbAH1mQrhho2WuX3R9YF9zD m/Kdtr3EcFiN5nwYGFbU5VjNNb7xLsRUIT4QCslI2cyIKKQNPfZNkxPr0afG4N4z2TjO p94dhoMJAJeKHm9DtSeP/i9X1OM8ia0KRaiP0tTT2B8PipyMK1wy9XZWwwtLNOV3hxtC BGtgITu/KpbWOmKVS/b8zCJILK6b7zjErZK7QYe7nUx41fHPERQ45mzY+I8qL1g0Q+vq c9dm7VWSG9s4f5b4SmpZoVJ/wFPAmaZON+Zw5/qAwgkTxoeu/I7F1Gz1CAhFjpJfuw4I mLmw== X-Gm-Message-State: ANoB5pkzt0857Xey6hrLumUWiibN4BLedLJ9XwWeNTFW1pf6tNeU6OUz sgjw50dHatzeaCZcJMn+mWAJ9g== X-Received: by 2002:a17:906:53cd:b0:78c:1f2f:233e with SMTP id p13-20020a17090653cd00b0078c1f2f233emr19534963ejo.307.1668632013651; Wed, 16 Nov 2022 12:53:33 -0800 (PST) Received: from blmsp.fritz.box ([2001:4090:a244:804b:353b:565:addf:3aa7]) by smtp.gmail.com with ESMTPSA id kv17-20020a17090778d100b007aece68483csm6782828ejc.193.2022.11.16.12.53.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 12:53:33 -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 12/15] can: tcan4x5x: Remove invalid write in clear_interrupts Date: Wed, 16 Nov 2022 21:53:05 +0100 Message-Id: <20221116205308.2996556-13-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221116205308.2996556-1-msp@baylibre.com> References: <20221116205308.2996556-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?1749687736491009583?= X-GMAIL-MSGID: =?utf-8?q?1749687736491009583?= Register 0x824 TCAN4X5X_MCAN_INT_REG is a read-only register. Any writes to this register do not have any effect. Remove this write. The m_can driver aldready clears the interrupts in m_can_isr() by writing to M_CAN_IR which is translated to register 0x1050 which is a writable version of this register. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/tcan4x5x-core.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/net/can/m_can/tcan4x5x-core.c b/drivers/net/can/m_can/tcan4x5x-core.c index 41645a24384c..1fec394b3517 100644 --- a/drivers/net/can/m_can/tcan4x5x-core.c +++ b/drivers/net/can/m_can/tcan4x5x-core.c @@ -204,11 +204,6 @@ static int tcan4x5x_clear_interrupts(struct m_can_classdev *cdev) if (ret) return ret; - ret = tcan4x5x_write_tcan_reg(cdev, TCAN4X5X_MCAN_INT_REG, - TCAN4X5X_ENABLE_MCAN_INT); - if (ret) - return ret; - ret = tcan4x5x_write_tcan_reg(cdev, TCAN4X5X_INT_FLAGS, TCAN4X5X_CLEAR_ALL_INT); if (ret) From patchwork Wed Nov 16 20:53:06 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: 21269 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp57530wrr; Wed, 16 Nov 2022 12:57:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Sz2rYd00WnFAxkyXLVW067FQfsqwWkHNJ/GUzl03n1x5ragz3s24icoWBt65PUeWh6zv5 X-Received: by 2002:a63:ed13:0:b0:46f:aefa:340c with SMTP id d19-20020a63ed13000000b0046faefa340cmr21880150pgi.525.1668632261647; Wed, 16 Nov 2022 12:57:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668632261; cv=none; d=google.com; s=arc-20160816; b=h0qMSbC0mkpYSsE5wSelC1SP31o/ZS3LRZGmAQtx2sTCfvUYBrTE3H5tDtn9bWt3An RRCWN0RmWwVdEAwKEEvVfdWz7DL0BrJw/QDLdYMc6hbxtf4qTdlFYk35JK5B72nIfRlQ DkiOJZJPTPxFhtB51t9uGQ/9qsORRsH7OfsFsux5+JERblBG4TdhNZEsLKBIYR5aVYMw yRuULjOMKpXWUdJ8JqpiDc0w0xuPNMr9clUEJgOYjPV5wPZcIpoBkXzavHsaOdrDnewW VF3XUCOBINsTwyOravRdGI59rEXkj1i7r7SwZ+VCMsdc3jXK6nhuy6wCLIHSaZ5kyCdA hApw== 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=81I+3EQI2P3P+v8VM+hyFuPqC5NfWDfLreVqvTuq6Uc=; b=LpbShNuEy/jSApPRGB2ma2jP7qRVso2xCwc+YRMYWOjvrZrLYPYZnsKf27efDffnKb fugXAJWCFrHBUMkV6m0cSU2zDQRfEJUXUeImg5EAX5X1NtdgP/Y7mfEYSKYmzDX+AZ2P er++tZ3+ArUg2Ewj1KsuSBMhxlAkfiHdNKCdl26ofA032juu6EHwDinQh4UhwKM6OwaF 8VLBD/Nb/boD2CkF5Ib+oS2u6KU8W62NSocM9XkH9bHZvKdciWFFAWL9Ot6ijzhqfE5r V2bO8l08mCpgzT2UDn726RzlWTnILtH5cBpG4D/UD6l8y4edIzN7hJ6N34YOW3LnB4eL 5Oiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=XGipdapc; 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 j18-20020a170902da9200b00178b95aa01fsi17769468plx.614.2022.11.16.12.57.29; Wed, 16 Nov 2022 12:57:41 -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=XGipdapc; 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 S239082AbiKPUzF (ORCPT + 99 others); Wed, 16 Nov 2022 15:55:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238523AbiKPUx7 (ORCPT ); Wed, 16 Nov 2022 15:53:59 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D733659B for ; Wed, 16 Nov 2022 12:53:34 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id ft34so47069334ejc.12 for ; Wed, 16 Nov 2022 12:53:34 -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=81I+3EQI2P3P+v8VM+hyFuPqC5NfWDfLreVqvTuq6Uc=; b=XGipdapc5eAZDNwW6fDCnAfCBr6vjHFnAILuue5kTPnrIATThKIRIsIhP+z2KZwAGM 6xUobtU2sa5lE10jjJuuGNMVisNd9drGLcSzv6wmClcvUclmWAmCV8h2h8ZRfZofPWkk EuEnru3SohqNWb7K9iS8av9HqIlHgNU2e25Giu//b4SVp9G8/OrJD+9wghG9ckRYwxtE X4eRS4eDvt6HAqph+8CzeaqjwtSLUZ5iJ15PYapHdGYS35arY+2biLqjbCfQZ9EXjLtu DWd4+/L/CNt5DvXwsWmmL929RLKDfwctrtrmB45Qp5SKPT2mizdg61T0XLQntWDtK1YX cZpA== 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=81I+3EQI2P3P+v8VM+hyFuPqC5NfWDfLreVqvTuq6Uc=; b=u4p+mzaJC5kmLIuJkQ5065Ir3M88YiK3D7RITPWAuJbr7fC4urTjrLqwrxLCivmqUT nyG6e7kfE0L/vUh2GfNShQ7LxmJdo2zOriJrJvFjt6ZVid1cN80EM1bqpN9KEol2BIBr tEIQRtgHk/gNJscD3BobytREE7CXAjbbQtvuO3MkQzb73IAnc1Xndh1YYAMYGQ4OrmxK BHXVg4ieXlNPMwRAUoOPhzcQkzvxkdUw4A/DUrY5lI1Us44C4IHUI/dcEiW1ZcyLj9Fp 5zIjjOwdn4Z+VgNR3NKps5AG1lorL9vZwUwjKvh6//N6nlSxrPml9T1gBS43UT/71JnT AThw== X-Gm-Message-State: ANoB5pkrd6bWtkLmUGxToQ7Ld2BqqcV7fnAaSHXRwbzN2bnb6NEbzz7C wNsvTUEjq+NaeUs7ygtw7V0ieA== X-Received: by 2002:a17:906:814:b0:78e:ebd:bf96 with SMTP id e20-20020a170906081400b0078e0ebdbf96mr19030638ejd.625.1668632014449; Wed, 16 Nov 2022 12:53:34 -0800 (PST) Received: from blmsp.fritz.box ([2001:4090:a244:804b:353b:565:addf:3aa7]) by smtp.gmail.com with ESMTPSA id kv17-20020a17090778d100b007aece68483csm6782828ejc.193.2022.11.16.12.53.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 12:53:34 -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 13/15] can: tcan4x5x: Fix use of register error status mask Date: Wed, 16 Nov 2022 21:53:06 +0100 Message-Id: <20221116205308.2996556-14-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221116205308.2996556-1-msp@baylibre.com> References: <20221116205308.2996556-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?1749687742744031517?= X-GMAIL-MSGID: =?utf-8?q?1749687742744031517?= TCAN4X5X_ERROR_STATUS is not a status register that needs clearing during interrupt handling. Instead this is a masking register that masks error interrupts. Writing TCAN4X5X_CLEAR_ALL_INT to this register effectively masks everything. Rename the register and mask all error interrupts only once by writing to the register in tcan4x5x_init. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/tcan4x5x-core.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/can/m_can/tcan4x5x-core.c b/drivers/net/can/m_can/tcan4x5x-core.c index 1fec394b3517..efa2381bf85b 100644 --- a/drivers/net/can/m_can/tcan4x5x-core.c +++ b/drivers/net/can/m_can/tcan4x5x-core.c @@ -10,7 +10,7 @@ #define TCAN4X5X_DEV_ID1 0x04 #define TCAN4X5X_REV 0x08 #define TCAN4X5X_STATUS 0x0C -#define TCAN4X5X_ERROR_STATUS 0x10 +#define TCAN4X5X_ERROR_STATUS_MASK 0x10 #define TCAN4X5X_CONTROL 0x14 #define TCAN4X5X_CONFIG 0x800 @@ -204,12 +204,7 @@ static int tcan4x5x_clear_interrupts(struct m_can_classdev *cdev) if (ret) return ret; - ret = tcan4x5x_write_tcan_reg(cdev, TCAN4X5X_INT_FLAGS, - TCAN4X5X_CLEAR_ALL_INT); - if (ret) - return ret; - - return tcan4x5x_write_tcan_reg(cdev, TCAN4X5X_ERROR_STATUS, + return tcan4x5x_write_tcan_reg(cdev, TCAN4X5X_INT_FLAGS, TCAN4X5X_CLEAR_ALL_INT); } @@ -229,6 +224,11 @@ static int tcan4x5x_init(struct m_can_classdev *cdev) if (ret) return ret; + ret = tcan4x5x_write_tcan_reg(cdev, TCAN4X5X_ERROR_STATUS_MASK, + TCAN4X5X_CLEAR_ALL_INT); + if (ret) + return ret; + /* Zero out the MCAN buffers */ ret = m_can_init_ram(cdev); if (ret) From patchwork Wed Nov 16 20:53:07 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: 21272 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp59013wrr; Wed, 16 Nov 2022 13:01:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf7VaLiuD+3rd3eo1qwk5w8hpN4EHeunN5pw0NmWBE5D3yZ5nn9049QLFg9hFjMxnvwELxTb X-Received: by 2002:a17:906:c284:b0:7a1:6786:444f with SMTP id r4-20020a170906c28400b007a16786444fmr19058261ejz.409.1668632486734; Wed, 16 Nov 2022 13:01:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668632486; cv=none; d=google.com; s=arc-20160816; b=07Eo7hGCQ5WqVsVarB9K+xNjFPhfz/sVJRNRTdFktYbYDJVooo96+10qFUdIx6bNvP LuZAwnGGtjg5G1OmrwrDyZeFdLrcZmuCIiSsCg8eMrKsSMPWhy2lmI6iaIWfLuJWp0SU DH3fclunRd1J2jrw3sPRROAklmoFu8sih91c/l5tWGJKhr7WY5g8sNSF4yGIJEzIAyT/ zDVBl005sDZSX9MnIm3cS5LTQNlGtoH8s1fcW1BIWHvulUcw/qzaETUZZ99homZwAQfT 8hfGrI0sD1ls/a01VxGTz2xp0aDkt2m3Nns3YfI/6avFsXvTbZ8klARxdyyLo3xagvIa vqQg== 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=YM61plGO68WaURjQUGMFYN3EyOhHGwttCZUHVzMzSmk=; b=iOiPHEAZ9v1FtKQAzwoMO164GcdgH+MBkity/L1k6eGxVh4qlb6y4HocRE/eCwKrli ABqIjLUjwmyYFuPrBc5tT9rjCZMNN3df+36roJe40CJa9sfWl5IFM4CJ2SXuvdKHDdKe NkX4d+bkqOZ41qTpZldkTqWANfgn5WFRyAo27xU3ih/Y3nKQNp8EUz/YetfNN6PrFTWt RkTfUdIwPNqiSR8Fp67kVPMzSHkWnZnlmwp8Kp8wxRt53T4eig0JySyr3c6GinRa/v0l RedaWMzGrYvMnbf8vC4vDIoxH4Kos5/zwT4KAZriy6dwENxDgIYWVTNbVu3Pyf2U50S4 KqSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=Ai+PNsCF; 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 n4-20020a170906840400b00779e6c93108si12659260ejx.598.2022.11.16.13.01.02; Wed, 16 Nov 2022 13:01:26 -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=Ai+PNsCF; 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 S234019AbiKPU5V (ORCPT + 99 others); Wed, 16 Nov 2022 15:57:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238685AbiKPUyB (ORCPT ); Wed, 16 Nov 2022 15:54:01 -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 95E809FE5 for ; Wed, 16 Nov 2022 12:53:35 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id ft34so47069415ejc.12 for ; Wed, 16 Nov 2022 12:53:35 -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=YM61plGO68WaURjQUGMFYN3EyOhHGwttCZUHVzMzSmk=; b=Ai+PNsCF8RUwtUbnUOAUElOEHQCIBtfvFr4FFEPhc4TBV1LylFALavmdFCQF1QzYq/ qDLB9z/9yjs+tm0zJDPFsIHbvWfXxkuKo96Mw4ScW7PN57/EQlnKCQF3ks2yEEWGQS4M fOkPJMw5pzIgSHSJxAAN/m0vsKCwGMVMEeXP40tQCc2n8qnsGB+hhZa1DA4jL5zut82i 7bC2rKxw1gYmVP6CvdtAOEt2IjHSFaOJPPC4uXz5zk7Yf+apbdDgU6asT4dd1JJgsrsU hgu+opVs9duZiov5egbrN5iBHXVuLoqZhPNnLyLFx6oOgUWVE2t7GU+wFAKEtKmsFXq3 kPfA== 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=YM61plGO68WaURjQUGMFYN3EyOhHGwttCZUHVzMzSmk=; b=O1NKRm/zLJR1/GfQXrZFcyjwONuOCBJI80uRiM1kZkIs5guxIA3W1ukZJZ/E/UPxv9 TNXBDhA6MnWXGmUOKwfs3BKokPwwvvPxT/+gQAi8FX2WtwNygNeQx9GBd441myCvxQHy YUkLzUfS9dj+sSZMCp931OgUq3isw1wNiAjSxChXMdQNcqLXLh/B+/t4Qo/PG3kKRa5P A7Q0+iOlw3VpLlISvo9QllRalrAoBUWBz6o6NLOzStTUBr84L5oS9/yOol00E9ZQF0Vb 6Uj9jX5nu2jTUsMHRwb19x4ySwUUd0GOEylfwSPuk91/eHSf5514GK89sebT9GsfGNji yfCA== X-Gm-Message-State: ANoB5pkhlhp88yIYSAEZAQMghLyjp84sDKcukrW0VdA6C0aH2SuKx41m hai4ObDyhhCrEeWdyb8OO+UKo3uqHrN58A== X-Received: by 2002:a17:907:c78d:b0:7af:113a:7416 with SMTP id tz13-20020a170907c78d00b007af113a7416mr10052021ejc.16.1668632015148; Wed, 16 Nov 2022 12:53:35 -0800 (PST) Received: from blmsp.fritz.box ([2001:4090:a244:804b:353b:565:addf:3aa7]) by smtp.gmail.com with ESMTPSA id kv17-20020a17090778d100b007aece68483csm6782828ejc.193.2022.11.16.12.53.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 12:53:34 -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 14/15] can: tcan4x5x: Fix register range of first block Date: Wed, 16 Nov 2022 21:53:07 +0100 Message-Id: <20221116205308.2996556-15-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221116205308.2996556-1-msp@baylibre.com> References: <20221116205308.2996556-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?1749687978243452344?= X-GMAIL-MSGID: =?utf-8?q?1749687978243452344?= According to the datasheet 0x1c is the last register in the first block, not register 0x2c. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/tcan4x5x-regmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/can/m_can/tcan4x5x-regmap.c b/drivers/net/can/m_can/tcan4x5x-regmap.c index 26e212b8ca7a..d4b79d2d4598 100644 --- a/drivers/net/can/m_can/tcan4x5x-regmap.c +++ b/drivers/net/can/m_can/tcan4x5x-regmap.c @@ -91,7 +91,7 @@ static int tcan4x5x_regmap_read(void *context, } static const struct regmap_range tcan4x5x_reg_table_yes_range[] = { - regmap_reg_range(0x0000, 0x002c), /* Device ID and SPI Registers */ + regmap_reg_range(0x0000, 0x001c), /* Device ID and SPI Registers */ regmap_reg_range(0x0800, 0x083c), /* Device configuration registers and Interrupt Flags*/ regmap_reg_range(0x1000, 0x10fc), /* M_CAN */ regmap_reg_range(0x8000, 0x87fc), /* MRAM */ From patchwork Wed Nov 16 20:53:08 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: 21276 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp60572wrr; Wed, 16 Nov 2022 13:04:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf6mqeaLmcCj8rjJWc6jDXfYy0b0mb7hRdYHxZyB4+Kc7DAF6RQBfP3Rf3at1497HpUzdt1H X-Received: by 2002:a17:906:bc83:b0:7b2:8008:6466 with SMTP id lv3-20020a170906bc8300b007b280086466mr4750779ejb.347.1668632659257; Wed, 16 Nov 2022 13:04:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668632659; cv=none; d=google.com; s=arc-20160816; b=Uc+GJDHDHRDQJgw//5ZRbQm1cMras+A2KQ/L++DpR5G7KkT92ZemUSJdqHvKu8UxO9 KI2crHbAp5pLeZkEJWuzfX0SU+Tioi+OB0I5UIAGxwzOdstkzemZ2sO8BZRa/rNGEQH9 Ec64V3POWFdEg53XuV7ewq48NKSUoo8MfQq7+kkUUgdqdMTtlRDYB8FJp5K7wBFQv3ld E4IBCiOE3KElGAP/94bTtDV//Gs0SclwWA56o4TCj0LHl3HG2tkJm/KH012mj6MtbhMv Wk7aobG7BbfyX/9hSIg1Yk1n6B+lXTAfPfEPOtV5laPQjMzzD+7jdqGfIKZlJY4mCv7b hgPQ== 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=CeVee7WTu+MIVK7s97PRG5d4Tw3kKV6cU2vVtZ3DItQ=; b=OBkI+weGA3BYG9dQTB4oP+lJ7a/oknbBZgQ+de3V4jOIwsTOb0j8FaK4UurwJX0WiT WEnE5r0jNw5SFb0NRk8KgwOc7NgwKgJLu2lLRqni81IPZOdYeYo3SyXxfj24CQvEF6eS pCDfIo7fxVmhmmhpWMElSvB4lkoEen1rI0bfi5IQkV68s6sz/0Z6uN+vENnUb9wbjENY zlLp3/9MU9F3DK7zxq/+RxhAmRwuV9Z3JW7vNKdIVBhctEx0wOQt6yGdi72uTvFV+f6i wzADRe5qdUkp/RH0eWqg5EKfQZMhQjWsEyv0T5vLCTlXGAI8dx/EBMv6ebBM39Mjh5IV eqUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=ofPkZh1s; 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 hd39-20020a17090796a700b007acf3aed468si15559770ejc.786.2022.11.16.13.03.55; Wed, 16 Nov 2022 13:04:19 -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=ofPkZh1s; 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 S236124AbiKPU5j (ORCPT + 99 others); Wed, 16 Nov 2022 15:57:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234407AbiKPUyC (ORCPT ); Wed, 16 Nov 2022 15:54:02 -0500 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D89D5FE0 for ; Wed, 16 Nov 2022 12:53:36 -0800 (PST) Received: by mail-ed1-x530.google.com with SMTP id a5so28422895edb.11 for ; Wed, 16 Nov 2022 12:53:36 -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=CeVee7WTu+MIVK7s97PRG5d4Tw3kKV6cU2vVtZ3DItQ=; b=ofPkZh1sJHCSjcXBt5MSofHDe4685qhi1/Uc6LWnRd5EToxTmQIbpUn6ccrEQAQAns SXavK0S2kbOubR/NRJ7cDZLF6RKWaQ4G757sspLKT7U2Nq1FQa21mr8+z+tgJN1JAHar bAGuACN8zSgXgSFsxzahOcOiGZtZqtaI3ADgt8nVKKhB/xQ5NRUK8cjr9uuVpDjrECJG ZIM8hXLVCMHjmTEFYN/pf8GLR66Zi1gz5BAhY62LqokcHeYn5zUnYo+GMZQSk9oRLSrz 5o59LVtNJfrNkQhOE//fxGY7XlXdPB/LDl9sjti2Spkq8u58gt9NoQCSLUs3GqyCorT1 nZKA== 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=CeVee7WTu+MIVK7s97PRG5d4Tw3kKV6cU2vVtZ3DItQ=; b=0cg8XZD3zRCUtgcE4eiNPsS98XYX/ZX16E7fTGbMPOG/8CokZK2cKo+gknUyglhR89 jxjX6YTT77d+vcTwSlEaGwwWMdV5P4j5t8YiDhQzCJb4XJq8MTeQTRZMNWOc2cc8wdJM 6/n8ETZD/AFJ+Q/XuC8snkwlLTGytXiVLiL5V1UW+8UQgwGyihk8q2Wf63Tjo/zToR0r xqAPlzxGl96v7DoE+bGQRa9kAtnX52WVI4ut2Srsv5rE+FiT79zZJ4SIcJaoWtz2OWb4 MayfroTyJO622nQ0Ys/suKtdLpo8vsBOQkltcmreruOnCmNOiauVoUoTwK3GUSd7eE0w 6qwA== X-Gm-Message-State: ANoB5pkUrLNcRy6MOtqdrw9mRrPsPryU664AgdyCx+YaBkDML2EoTmM9 aiqS1YW0OIEiRl5SoBUWo7ataP3KNEk3sg== X-Received: by 2002:a05:6402:17c2:b0:459:443a:faf4 with SMTP id s2-20020a05640217c200b00459443afaf4mr20696086edy.297.1668632016031; Wed, 16 Nov 2022 12:53:36 -0800 (PST) Received: from blmsp.fritz.box ([2001:4090:a244:804b:353b:565:addf:3aa7]) by smtp.gmail.com with ESMTPSA id kv17-20020a17090778d100b007aece68483csm6782828ejc.193.2022.11.16.12.53.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 12:53:35 -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 15/15] can: tcan4x5x: Specify separate read/write ranges Date: Wed, 16 Nov 2022 21:53:08 +0100 Message-Id: <20221116205308.2996556-16-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221116205308.2996556-1-msp@baylibre.com> References: <20221116205308.2996556-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?1749688159342365050?= X-GMAIL-MSGID: =?utf-8?q?1749688159342365050?= Specify exactly which registers are read/writeable in the chip. This is supposed to help detect any violations in the future. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/tcan4x5x-regmap.c | 43 +++++++++++++++++++++---- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/drivers/net/can/m_can/tcan4x5x-regmap.c b/drivers/net/can/m_can/tcan4x5x-regmap.c index d4b79d2d4598..19215c39cd5b 100644 --- a/drivers/net/can/m_can/tcan4x5x-regmap.c +++ b/drivers/net/can/m_can/tcan4x5x-regmap.c @@ -90,16 +90,47 @@ static int tcan4x5x_regmap_read(void *context, return 0; } -static const struct regmap_range tcan4x5x_reg_table_yes_range[] = { +static const struct regmap_range tcan4x5x_reg_table_wr_range[] = { + /* Device ID and SPI Registers */ + regmap_reg_range(0x000c, 0x001c), + /* Device configuration registers and Interrupt Flags*/ + regmap_reg_range(0x0800, 0x080c), + regmap_reg_range(0x0814, 0x0814), + regmap_reg_range(0x0820, 0x0820), + regmap_reg_range(0x0830, 0x0830), + /* M_CAN */ + regmap_reg_range(0x100c, 0x102c), + regmap_reg_range(0x1048, 0x1048), + regmap_reg_range(0x1050, 0x105c), + regmap_reg_range(0x1080, 0x1088), + regmap_reg_range(0x1090, 0x1090), + regmap_reg_range(0x1098, 0x10a0), + regmap_reg_range(0x10a8, 0x10b0), + regmap_reg_range(0x10b8, 0x10c0), + regmap_reg_range(0x10c8, 0x10c8), + regmap_reg_range(0x10d0, 0x10d4), + regmap_reg_range(0x10e0, 0x10e4), + regmap_reg_range(0x10f0, 0x10f0), + regmap_reg_range(0x10f8, 0x10f8), + /* MRAM */ + regmap_reg_range(0x8000, 0x87fc), +}; + +static const struct regmap_range tcan4x5x_reg_table_rd_range[] = { regmap_reg_range(0x0000, 0x001c), /* Device ID and SPI Registers */ regmap_reg_range(0x0800, 0x083c), /* Device configuration registers and Interrupt Flags*/ regmap_reg_range(0x1000, 0x10fc), /* M_CAN */ regmap_reg_range(0x8000, 0x87fc), /* MRAM */ }; -static const struct regmap_access_table tcan4x5x_reg_table = { - .yes_ranges = tcan4x5x_reg_table_yes_range, - .n_yes_ranges = ARRAY_SIZE(tcan4x5x_reg_table_yes_range), +static const struct regmap_access_table tcan4x5x_reg_table_wr = { + .yes_ranges = tcan4x5x_reg_table_wr_range, + .n_yes_ranges = ARRAY_SIZE(tcan4x5x_reg_table_wr_range), +}; + +static const struct regmap_access_table tcan4x5x_reg_table_rd = { + .yes_ranges = tcan4x5x_reg_table_rd_range, + .n_yes_ranges = ARRAY_SIZE(tcan4x5x_reg_table_rd_range), }; static const struct regmap_config tcan4x5x_regmap = { @@ -107,8 +138,8 @@ static const struct regmap_config tcan4x5x_regmap = { .reg_stride = 4, .pad_bits = 8, .val_bits = 32, - .wr_table = &tcan4x5x_reg_table, - .rd_table = &tcan4x5x_reg_table, + .wr_table = &tcan4x5x_reg_table_wr, + .rd_table = &tcan4x5x_reg_table_rd, .max_register = TCAN4X5X_MAX_REGISTER, .cache_type = REGCACHE_NONE, .read_flag_mask = (__force unsigned long)