Re: [PATCH] can: m_can: m_can_dev_setup(): set CCCR_INIT bit earlier

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 17.12.2024 13:56:56, Renjaya Raga Zenta wrote:
> When OS reboot, device is still in normal mode. Probing
> will fail with this error message:
> 
>   refusing to configure device when in normal mode
>   (unnamed net_device) (uninitialized): failed to enable configuration mode
>   Failed registering m_can device -EBUSY
> 
> The log can be traced, it's from:
>   m_can_dev_setup
>     -> m_can_niso_supported
>       -> m_can_config_enable
>         -> m_can_cccr_update_bits
> 
> In commit cd5a46ce6fa6 ("can: m_can: don't enable transceiver when
> probing"), m_can_niso_supported() was reworked to call
> m_can_config_enable(). However, in m_can_config_enable(), it's noted
> that CCCR_INIT must be set in order to set CCCR_CCE. The CCCR_INIT
> bit is set later in m_can_dev_setup().
> 
> To fix the problem, move forcing standby mode (set CCCR_INIT) lines
> before m_can_niso_supported() line in m_can_dev_setup().
> 
> Fixes: cd5a46ce6fa6 ("can: m_can: don't enable transceiver when probing")
> Signed-off-by: Renjaya Raga Zenta <ragazenta@xxxxxxxxx>
> ---
> Link: https://lore.kernel.org/linux-can/20241106123700.119074-1-renjaya.zenta@xxxxxxxxxxxxxxx

Can you check if
https://lore.kernel.org/all/e247f331cb72829fcbdfda74f31a59cbad1a6006.1728288535.git.matthias.schiffer@xxxxxxxxxxxxxxx/
fixes your problem?

Marc

> ---
>  drivers/net/can/m_can/m_can.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
> index 533bcb77c9f934e5840b076ded948f8256ad2ad0..9345b181c5e31e1507a4dadc31e5f15545e1dc98 100644
> --- a/drivers/net/can/m_can/m_can.c
> +++ b/drivers/net/can/m_can/m_can.c
> @@ -1685,7 +1685,7 @@ static int m_can_niso_supported(struct m_can_classdev *cdev)
>  static int m_can_dev_setup(struct m_can_classdev *cdev)
>  {
>  	struct net_device *dev = cdev->net;
> -	int m_can_version, err, niso;
> +	int m_can_version, err, ret, niso;
>  
>  	m_can_version = m_can_check_core_release(cdev);
>  	/* return if unsupported version */
> @@ -1710,6 +1710,12 @@ static int m_can_dev_setup(struct m_can_classdev *cdev)
>  		CAN_CTRLMODE_FD |
>  		CAN_CTRLMODE_ONE_SHOT;
>  
> +	/* Forcing standby mode should be redundant, as the chip should be in
> +	 * standby after a reset. Write the INIT bit anyways, should the chip
> +	 * be configured by previous stage.
> +	 */
> +	ret = m_can_cccr_update_bits(cdev, CCCR_INIT, CCCR_INIT);

You don't check the return value.

> +
>  	/* Set properties depending on M_CAN version */
>  	switch (cdev->version) {
>  	case 30:
> @@ -1746,11 +1752,7 @@ static int m_can_dev_setup(struct m_can_classdev *cdev)
>  		return -EINVAL;
>  	}
>  
> -	/* Forcing standby mode should be redundant, as the chip should be in
> -	 * standby after a reset. Write the INIT bit anyways, should the chip
> -	 * be configured by previous stage.
> -	 */
> -	return m_can_cccr_update_bits(cdev, CCCR_INIT, CCCR_INIT);
> +	return ret;
>  }
>  
>  static void m_can_stop(struct net_device *dev)
> 
> ---
> base-commit: c7d876495ffad298d7f5fa252000c80fd4fd1b74
> change-id: 20241217-m_can_fix-af60055d7c96
> 
> Best regards,
> -- 
> Renjaya Raga Zenta <ragazenta@xxxxxxxxx>
> 
> 
> 

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux