From patchwork Wed Sep 11 08:45:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Kleine-Budde X-Patchwork-Id: 13799926 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7E972EE021C for ; Wed, 11 Sep 2024 08:47:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vemofKWu/83DPB+exh9tkq26QKsHiK3LSmcZfByfCyQ=; b=usBArxMyIuZ7CkVMAc22MUA4qj E2EucCM3MCUjDiyNucsT+82pZBnOh1yrYE1MNTDGabEe7MNyH9Nh9uPaaju0/DuoTW3YbXCUqbQKa 3wPynab+9v5DvGhPPj/f6lCZhSpZBVUiNzw3yRiGUIa5UOCLVyu2JEc9rE6vL1DUIGQ1ce2Cra98r IYc1qor24b19d7VNBkc3yGGlq7q1qaK1fWLLcbbuJB9hXvWG9e2Ag9QJRJGTpNB8EQ7pU3oWEoCWN QZBXwWZqDTpIbbMMBpxrgRexnjYFvQF76iu2T9ky1PJCdRnHAYTYGetqH5C9sUQbC/IJdLLmBALqj vwnGbi7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1soJ0q-00000008kV2-0j63; Wed, 11 Sep 2024 08:47:44 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1soIyk-00000008jtv-1iuA for linux-arm-kernel@lists.infradead.org; Wed, 11 Sep 2024 08:45:37 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1soIyj-0002bN-28 for linux-arm-kernel@lists.infradead.org; Wed, 11 Sep 2024 10:45:33 +0200 Received: from [2a0a:edc0:0:b01:1d::7b] (helo=bjornoya.blackshift.org) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1soIyi-0075ys-Jw for linux-arm-kernel@lists.infradead.org; Wed, 11 Sep 2024 10:45:32 +0200 Received: from dspam.blackshift.org (localhost [127.0.0.1]) by bjornoya.blackshift.org (Postfix) with SMTP id 4FAA3338145 for ; Wed, 11 Sep 2024 08:45:32 +0000 (UTC) Received: from hardanger.blackshift.org (unknown [172.20.34.65]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by bjornoya.blackshift.org (Postfix) with ESMTPS id 115B2338137; Wed, 11 Sep 2024 08:45:31 +0000 (UTC) Received: from [172.20.34.65] (localhost [::1]) by hardanger.blackshift.org (OpenSMTPD) with ESMTP id 0a04ff54; Wed, 11 Sep 2024 08:45:30 +0000 (UTC) From: Marc Kleine-Budde Date: Wed, 11 Sep 2024 10:45:25 +0200 Subject: [PATCH can-next 1/2] can: rockchip_canfd: rkcanfd_timestamp_init(): rework delay calculation MIME-Version: 1.0 Message-Id: <20240911-can-rockchip_canfd-fixes-v1-1-5ce385b5ab10@pengutronix.de> References: <20240911-can-rockchip_canfd-fixes-v1-0-5ce385b5ab10@pengutronix.de> In-Reply-To: <20240911-can-rockchip_canfd-fixes-v1-0-5ce385b5ab10@pengutronix.de> To: kernel@pengutronix.de, Vincent Mailhol , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Heiko Stuebner Cc: linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Marc Kleine-Budde , Arnd Bergmann X-Mailer: b4 0.15-dev-88a27 X-Developer-Signature: v=1; a=openpgp-sha256; l=1358; i=mkl@pengutronix.de; h=from:subject:message-id; bh=9WfFS70YrDr2qrfetTrD2fcBkV55eVvJHa3bbG4uxs8=; b=owEBbQGS/pANAwAKASg4oj56LbxvAcsmYgBm4VinquE+Tws44QEClswYLm8kNwf80a6ISQYBA mPD6Zr1Ds+JATMEAAEKAB0WIQRQQLqG4LYE3Sm8Pl8oOKI+ei28bwUCZuFYpwAKCRAoOKI+ei28 b0oAB/4g5Iqh2BWMbyXjya4wJb266mMCniZpg89eUuNb1jSWxUfSFVOkqdif+aLiaQ+MPiY/2fS oR1lDkgLs5zbSMwZgK5GnPgDtS7ziBYK20IdVE8Li5COjb8Wti/36hW6bPvRJ/1KMuDvJkZMD+m vnUP8O+8KBEBzp4YqgWSKb+XKgMt2ETWuoZscN6J7rWDrHmaavJCTBq82TpKUCVyoFW3Hn17Q+K xR0Z/LtOibuy+X3SuQd1ogL4z7Hf5jVtNwrjxlfmpaKYIseJCBEJMFM9r/MBmS/3lhvKnvmNHKu f818F71y4FhIkTCQZvzbuqrlRxGBdgGQI5MpiUfuV8aVUW1S X-Developer-Key: i=mkl@pengutronix.de; a=openpgp; fpr=C1400BA0B3989E6FBC7D5B5C2B5EE211C58AEA54 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240911_014534_519947_1564B701 X-CRM114-Status: GOOD ( 13.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Arnd Bergmann Rework the delay calculation to only require a single 64-bit division. Signed-off-by: Arnd Bergmann [mkl: port to on-top of existing 32-bit division fix] Signed-off-by: Marc Kleine-Budde --- drivers/net/can/rockchip/rockchip_canfd-timestamp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/rockchip/rockchip_canfd-timestamp.c b/drivers/net/can/rockchip/rockchip_canfd-timestamp.c index fb1a8f4e62172b06570b95e6f32c4c0f70fe1ea7..43d4b572181215c50dda9d4f8cdb2d22b7938b38 100644 --- a/drivers/net/can/rockchip/rockchip_canfd-timestamp.c +++ b/drivers/net/can/rockchip/rockchip_canfd-timestamp.c @@ -71,8 +71,8 @@ void rkcanfd_timestamp_init(struct rkcanfd_priv *priv) max_cycles = div_u64(ULLONG_MAX, cc->mult); max_cycles = min(max_cycles, cc->mask); - work_delay_ns = div_u64(clocksource_cyc2ns(max_cycles, cc->mult, cc->shift), 3); - priv->work_delay_jiffies = nsecs_to_jiffies(work_delay_ns); + work_delay_ns = clocksource_cyc2ns(max_cycles, cc->mult, cc->shift); + priv->work_delay_jiffies = div_u64(work_delay_ns, 3u * NSEC_PER_SEC / HZ); INIT_DELAYED_WORK(&priv->timestamp, rkcanfd_timestamp_work); netdev_dbg(priv->ndev, "clock=%lu.%02luMHz bitrate=%lu.%02luMBit/s div=%u rate=%lu.%02luMHz mult=%u shift=%u delay=%lus\n", From patchwork Wed Sep 11 08:45:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Kleine-Budde X-Patchwork-Id: 13799927 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6AC38EE021C for ; Wed, 11 Sep 2024 08:48:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=s3CEqeUgW8Tjyg9c0XWGpMx8rkBL2/wkzvdN0j0nbjI=; b=1jv/kK18+BRdVUeZnX9J0iFczn 8tlHclVBJjQMO1lKjVzxuJDZ5qd4XJ2LJCIa3canKrHeUR23zg8lBkXd2ENI8XDRMFwEJ/BBLoVVF 14z3N5JARKvYW7UWH0a7OW4tcuAZBYiL+mHwj4RQnwjbu7u7ENiTJf9K18IssJjJ5B/KEoGBJDXlT uu9IqXTO5IP0HRZoSySqDGOYla1Ww1UThG3n+TcdpIDm6rJD3umYDxrkWTHmEUAeq3QXoK4Lj185P Nq2zs+NqEt2AiEYoUgYZ2GBzaKZwYvayp09Ty8OnNiil7IpnBMki9nPYz/kCqA5gsWYLUGM+eQSOL nsmyscdg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1soJ1r-00000008kpO-3K7Q; Wed, 11 Sep 2024 08:48:47 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1soIyk-00000008jtw-1iiW for linux-arm-kernel@lists.infradead.org; Wed, 11 Sep 2024 08:45:37 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1soIyj-0002ba-9u for linux-arm-kernel@lists.infradead.org; Wed, 11 Sep 2024 10:45:33 +0200 Received: from [2a0a:edc0:0:b01:1d::7b] (helo=bjornoya.blackshift.org) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1soIyi-0075z0-SA for linux-arm-kernel@lists.infradead.org; Wed, 11 Sep 2024 10:45:32 +0200 Received: from dspam.blackshift.org (localhost [127.0.0.1]) by bjornoya.blackshift.org (Postfix) with SMTP id 8478E338147 for ; Wed, 11 Sep 2024 08:45:32 +0000 (UTC) Received: from hardanger.blackshift.org (unknown [172.20.34.65]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by bjornoya.blackshift.org (Postfix) with ESMTPS id 29182338139; Wed, 11 Sep 2024 08:45:31 +0000 (UTC) Received: from [172.20.34.65] (localhost [::1]) by hardanger.blackshift.org (OpenSMTPD) with ESMTP id debe3747; Wed, 11 Sep 2024 08:45:30 +0000 (UTC) From: Marc Kleine-Budde Date: Wed, 11 Sep 2024 10:45:26 +0200 Subject: [PATCH can-next 2/2] can: rockchip_canfd: rkcanfd_handle_error_int_reg_ec(): fix decoding of error code register MIME-Version: 1.0 Message-Id: <20240911-can-rockchip_canfd-fixes-v1-2-5ce385b5ab10@pengutronix.de> References: <20240911-can-rockchip_canfd-fixes-v1-0-5ce385b5ab10@pengutronix.de> In-Reply-To: <20240911-can-rockchip_canfd-fixes-v1-0-5ce385b5ab10@pengutronix.de> To: kernel@pengutronix.de, Vincent Mailhol , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Heiko Stuebner Cc: linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Marc Kleine-Budde , Dan Carpenter X-Mailer: b4 0.15-dev-88a27 X-Developer-Signature: v=1; a=openpgp-sha256; l=1660; i=mkl@pengutronix.de; h=from:subject:message-id; bh=FYsbjJVzwxPaRyPqACbgrzhpJ2D/uLoe7SJ0dYP09Js=; b=owEBbQGS/pANAwAKASg4oj56LbxvAcsmYgBm4VioSw/JfPWRyX7TNulq+OD3P1if17X5AXUkc eelM/LXK+mJATMEAAEKAB0WIQRQQLqG4LYE3Sm8Pl8oOKI+ei28bwUCZuFYqAAKCRAoOKI+ei28 b3TBB/4tpzx27rhQMW8/qzL1OyS2I+lGF0hA0iAcYabRDbNQgvJc1eD2bwvuuXxGXgBBLIDSCrb mSRCs8Z0Tw0qWZJsbKCfjJq7+DgVi1vCjzQ2qFeDnhAPo4sMB5UTXrX1uf94WXVWPUfNapKPEMP mfb3zMgj/EPVH56I+aEmOPUqQtMnn/GORbtGgcOZx2bm/EsJ22trts64MkLFpIHE2U3I+95+0dL 8m2gAvI4noaXh2v9ntqEIfrS1OQFWptO46NKmHXWbmcUFkacbH6TrKCJ4abBKrF88Tuiv7sR6rw +6YiakHcHj2+T4aZpqHar3krvFG6Mvj7nOohp9OHkIJz5YKh X-Developer-Key: i=mkl@pengutronix.de; a=openpgp; fpr=C1400BA0B3989E6FBC7D5B5C2B5EE211C58AEA54 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240911_014534_504423_2104F2A9 X-CRM114-Status: GOOD ( 14.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Probably due to a copy/paste error rkcanfd_handle_error_int_reg_ec() checks twice if the RKCANFD_REG_ERROR_CODE_TX_ACK_EOF bit is set in reg_ec. Keep the correct check for RKCANFD_REG_ERROR_CODE_TX_ACK_EOF and remove the superfluous one. Reported-by: Dan Carpenter Closes: https://patch.msgid.link/9a46d10d-e4e3-40a5-8fb6-f4637959f124@stanley.mountain Fixes: ff60bfbaf67f ("can: rockchip_canfd: add driver for Rockchip CAN-FD controller") Signed-off-by: Marc Kleine-Budde --- drivers/net/can/rockchip/rockchip_canfd-core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/can/rockchip/rockchip_canfd-core.c b/drivers/net/can/rockchip/rockchip_canfd-core.c index 6883153e8fc15e82684d4f06447de3e88168b9ae..df18c85fc0784148d55d7a0086713555fb48c008 100644 --- a/drivers/net/can/rockchip/rockchip_canfd-core.c +++ b/drivers/net/can/rockchip/rockchip_canfd-core.c @@ -491,11 +491,9 @@ rkcanfd_handle_error_int_reg_ec(struct rkcanfd_priv *priv, struct can_frame *cf, else if (reg_ec & RKCANFD_REG_ERROR_CODE_TX_CRC) cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; else if (reg_ec & RKCANFD_REG_ERROR_CODE_TX_ACK_EOF) - cf->data[3] = CAN_ERR_PROT_LOC_ACK; + cf->data[3] = CAN_ERR_PROT_LOC_ACK_DEL; else if (reg_ec & RKCANFD_REG_ERROR_CODE_TX_ACK) cf->data[3] = CAN_ERR_PROT_LOC_ACK; - else if (reg_ec & RKCANFD_REG_ERROR_CODE_TX_ACK_EOF) - cf->data[3] = CAN_ERR_PROT_LOC_ACK_DEL; /* RKCANFD_REG_ERROR_CODE_TX_ERROR */ else if (reg_ec & RKCANFD_REG_ERROR_CODE_TX_OVERLOAD) cf->data[2] |= CAN_ERR_PROT_OVERLOAD;