From: "Markus Schneider-Pargmann" <msp@baylibre.com>
To: "Marc Kleine-Budde" <mkl@pengutronix.de>,
"Chandrasekar Ramakrishnan" <rcsekar@samsung.com>,
"Vincent Mailhol" <mailhol.vincent@wanadoo.fr>,
"Patrik Flykt" <patrik.flykt@linux.intel.com>,
"Dong Aisheng" <b29396@freescale.com>,
"Fengguang Wu" <fengguang.wu@intel.com>,
"Varka Bhadram" <varkabhadram@gmail.com>,
"Wu Bo" <wubo.oduw@gmail.com>,
"Philipp Zabel" <p.zabel@pengutronix.de>
Cc: <linux-can@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<kernel@pengutronix.de>
Subject: Re: [PATCH 4/7] can: m_can: m_can_chip_config(): bring up interface in correct state
Date: Wed, 20 Aug 2025 11:00:51 +0200 [thread overview]
Message-ID: <DC74S0QJQ0JV.39VRZ1Y5JSEWS@baylibre.com> (raw)
In-Reply-To: <20250812-m_can-fix-state-handling-v1-4-b739e06c0a3b@pengutronix.de>
[-- Attachment #1: Type: text/plain, Size: 2067 bytes --]
Hi,
On Tue Aug 12, 2025 at 7:36 PM CEST, Marc Kleine-Budde wrote:
> 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")
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> ---
> drivers/net/can/m_can/m_can.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
> index b485d2f3d971..310a907cbb7e 100644
> --- a/drivers/net/can/m_can/m_can.c
> +++ b/drivers/net/can/m_can/m_can.c
> @@ -1607,6 +1607,7 @@ static int m_can_chip_config(struct net_device *dev)
> static int m_can_start(struct net_device *dev)
> {
> struct m_can_classdev *cdev = netdev_priv(dev);
> + u32 reg_psr;
> int ret;
>
> /* basic m_can configuration */
> @@ -1617,7 +1618,8 @@ 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;
> + reg_psr = m_can_read(cdev, M_CAN_PSR);
> + cdev->can.state = m_can_can_state_get_by_psr(reg_psr);
Previous patch makes sense for use here. But how is the state set back
in operation after mcan was in an error state? Maybe I missed the path
back to CAN_STATE_ERROR_ACTIVE somewhere?
Also CAN_STATE_ERROR_ACTIVE is set in resume() as well, should that also
read the PSR instead?
Ans lastly I don't like the function name, because of the repeated can,
maybe something like m_can_error_state_by_psr()?
Best
Markus
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 289 bytes --]
next prev parent reply other threads:[~2025-08-20 9:00 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-12 17:36 [PATCH 0/7] can: m_can: fix pm_runtime and CAN state handling Marc Kleine-Budde
2025-08-12 17:36 ` [PATCH 1/7] can: m_can: m_can_plat_remove(): add missing pm_runtime_disable() Marc Kleine-Budde
2025-08-19 8:22 ` Markus Schneider-Pargmann
2025-08-12 17:36 ` [PATCH 2/7] can: m_can: m_can_rx_handler(): only handle active interrupts Marc Kleine-Budde
2025-08-19 8:29 ` Markus Schneider-Pargmann
2025-09-09 14:07 ` Marc Kleine-Budde
2025-08-12 17:36 ` [PATCH 3/7] can: m_can: m_can_handle_state_errors(): fix CAN state transition to Error Active Marc Kleine-Budde
2025-08-20 8:49 ` Markus Schneider-Pargmann
2025-08-20 9:09 ` Markus Schneider-Pargmann
2025-09-09 14:28 ` Marc Kleine-Budde
2025-09-09 14:31 ` Marc Kleine-Budde
2025-09-09 14:38 ` Marc Kleine-Budde
2025-09-09 14:25 ` Marc Kleine-Budde
2025-08-12 17:36 ` [PATCH 4/7] can: m_can: m_can_chip_config(): bring up interface in correct state Marc Kleine-Budde
2025-08-20 9:00 ` Markus Schneider-Pargmann [this message]
2025-09-09 14:48 ` Marc Kleine-Budde
2025-08-12 17:36 ` [PATCH 5/7] can: m_can: fix CAN state in system PM Marc Kleine-Budde
2025-08-20 9:06 ` Markus Schneider-Pargmann
2025-08-12 17:36 ` [PATCH 6/7] can: m_can: m_can_get_berr_counter(): don't wake up controller if interface is down Marc Kleine-Budde
2025-08-12 17:36 ` [PATCH 7/7] can: m_can: add optional support for reset Marc Kleine-Budde
2025-08-13 8:17 ` Philipp Zabel
2025-08-13 8:34 ` Marc Kleine-Budde
2025-08-13 8:44 ` Marc Kleine-Budde
2025-08-13 8:17 ` [PATCH 0/7] can: m_can: fix pm_runtime and CAN state handling Philipp Zabel
2025-08-13 9:06 ` 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=DC74S0QJQ0JV.39VRZ1Y5JSEWS@baylibre.com \
--to=msp@baylibre.com \
--cc=b29396@freescale.com \
--cc=fengguang.wu@intel.com \
--cc=kernel@pengutronix.de \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mailhol.vincent@wanadoo.fr \
--cc=mkl@pengutronix.de \
--cc=p.zabel@pengutronix.de \
--cc=patrik.flykt@linux.intel.com \
--cc=rcsekar@samsung.com \
--cc=varkabhadram@gmail.com \
--cc=wubo.oduw@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.