From: Marc Kleine-Budde <mkl@pengutronix.de>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, linux-can@vger.kernel.org,
kernel@pengutronix.de, Marc Kleine-Budde <mkl@pengutronix.de>,
Markus Schneider-Pargmann <msp@baylibre.com>
Subject: [PATCH net 5/9] can: m_can: m_can_chip_config(): bring up interface in correct state
Date: Sun, 12 Oct 2025 16:20:49 +0200 [thread overview]
Message-ID: <20251012142836.285370-6-mkl@pengutronix.de> (raw)
In-Reply-To: <20251012142836.285370-1-mkl@pengutronix.de>
In some SoCs (observed on the STM32MP15) the M_CAN IP core keeps the
CAN state and CAN error counters over an internal reset cycle. An
external reset is not always possible, due to the shared reset with
the other CAN core. This caused the core not always be in Error Active
state when bringing up the controller.
Instead of always setting the CAN state to Error Active in
m_can_chip_config(), fix this by reading and decoding the Protocol
Status Regitser (PSR) and set the CAN state accordingly.
Fixes: e0d1f4816f2a ("can: m_can: add Bosch M_CAN controller support")
Reviewed-by: Markus Schneider-Pargmann <msp@baylibre.com>
Link: https://patch.msgid.link/20250929-m_can-fix-state-handling-v4-3-682b49b49d9a@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/m_can/m_can.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index ac864183a536..b6db5b57241c 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -1617,7 +1617,7 @@ static int m_can_start(struct net_device *dev)
netdev_queue_set_dql_min_limit(netdev_get_tx_queue(cdev->net, 0),
cdev->tx_max_coalesced_frames);
- cdev->can.state = CAN_STATE_ERROR_ACTIVE;
+ cdev->can.state = m_can_state_get_by_psr(cdev);
m_can_enable_all_interrupts(cdev);
--
2.51.0
next prev parent reply other threads:[~2025-10-12 14:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-12 14:20 [PATCH net 0/9] pull-request: can 2025-10-12 Marc Kleine-Budde
2025-10-12 14:20 ` [PATCH net 1/9] can: gs_usb: increase max interface to U8_MAX Marc Kleine-Budde
2025-10-12 14:20 ` [PATCH net 2/9] can: gs_usb: gs_make_candev(): populate net_device->dev_port Marc Kleine-Budde
2025-10-12 14:20 ` [PATCH net 3/9] can: m_can: m_can_plat_remove(): add missing pm_runtime_disable() Marc Kleine-Budde
2025-10-12 14:20 ` [PATCH net 4/9] can: m_can: m_can_handle_state_errors(): fix CAN state transition to Error Active Marc Kleine-Budde
2025-10-12 14:20 ` Marc Kleine-Budde [this message]
2025-10-12 14:20 ` [PATCH net 6/9] can: m_can: fix CAN state in system PM Marc Kleine-Budde
2025-10-12 14:20 ` [PATCH net 7/9] can: m_can: replace Dong Aisheng's old email address Marc Kleine-Budde
2025-10-12 14:20 ` [PATCH net 8/9] can: remove false statement about 1:1 mapping between DLC and length Marc Kleine-Budde
2025-10-12 14:20 ` [PATCH net 9/9] can: add Transmitter Delay Compensation (TDC) documentation Marc Kleine-Budde
2025-10-13 7:45 ` Paolo Abeni
2025-10-13 10:12 ` Vincent Mailhol
2025-10-15 9:43 ` Marc Kleine-Budde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251012142836.285370-6-mkl@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=davem@davemloft.net \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=msp@baylibre.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).