All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] can: m_can: tcan4x5x: put the device out of standby before register access
@ 2019-12-09 19:24 Sean Nyekjaer
  2019-12-09 19:44 ` Marc Kleine-Budde
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Sean Nyekjaer @ 2019-12-09 19:24 UTC (permalink / raw)
  To: mkl, dmurphy, linux-can; +Cc: Sean Nyekjaer, martin, stable

The m_can tries to detect of niso (canfd) is available while in standby,
this function results in the following error:

tcan4x5x spi2.0 (unnamed net_device) (uninitialized): Failed to init module
tcan4x5x spi2.0: m_can device registered (irq=84, version=32)
tcan4x5x spi2.0 can2: TCAN4X5X successfully initialized.

When the tcan device comes out of reset it comes out in standby mode.
The m_can driver tries to access the control register but fails due to
the device is in standby mode.
So this patch will put the tcan device in normal mode before the m_can
driver does the initialization.

Fixes: 5443c226ba91 ("can: tcan4x5x: Add tcan4x5x driver to the kernel")
Cc: stable@vger.kernel.org
Signed-off-by: Sean Nyekjaer <sean@geanix.com>
---
tcan4x5x_init will now be called from probe and the m_can call.
Would it be better to move the mode switch only to the probe function?

 drivers/net/can/m_can/tcan4x5x.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/can/m_can/tcan4x5x.c b/drivers/net/can/m_can/tcan4x5x.c
index 4e1789ea2bc3..3c30209ca84c 100644
--- a/drivers/net/can/m_can/tcan4x5x.c
+++ b/drivers/net/can/m_can/tcan4x5x.c
@@ -455,6 +455,8 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
 	if (ret)
 		goto out_clk;
 
+	tcan4x5x_init(mcan_class);
+
 	tcan4x5x_power_enable(priv->power, 1);
 
 	ret = m_can_class_register(mcan_class);
-- 
2.24.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] can: m_can: tcan4x5x: put the device out of standby before register access
  2019-12-09 19:24 [PATCH v2 1/2] can: m_can: tcan4x5x: put the device out of standby before register access Sean Nyekjaer
@ 2019-12-09 19:44 ` Marc Kleine-Budde
  2019-12-09 19:52   ` Sean Nyekjaer
  2019-12-09 22:07 ` Marc Kleine-Budde
  2020-01-02 15:46 ` Marc Kleine-Budde
  2 siblings, 1 reply; 7+ messages in thread
From: Marc Kleine-Budde @ 2019-12-09 19:44 UTC (permalink / raw)
  To: Sean Nyekjaer, dmurphy, linux-can; +Cc: martin, stable


[-- Attachment #1.1: Type: text/plain, Size: 420 bytes --]

On 12/9/19 8:24 PM, Sean Nyekjaer wrote:
> The m_can tries to detect of niso (canfd) is available while in standby,

What's "of niso"?

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] can: m_can: tcan4x5x: put the device out of standby before register access
  2019-12-09 19:44 ` Marc Kleine-Budde
@ 2019-12-09 19:52   ` Sean Nyekjaer
  0 siblings, 0 replies; 7+ messages in thread
From: Sean Nyekjaer @ 2019-12-09 19:52 UTC (permalink / raw)
  To: Marc Kleine-Budde, dmurphy, linux-can; +Cc: martin, stable



On 09/12/2019 20.44, Marc Kleine-Budde wrote:
> On 12/9/19 8:24 PM, Sean Nyekjaer wrote:
>> The m_can tries to detect of niso (canfd) is available while in standby,
> 
> What's "of niso"?
> 
Should have been "if niso" :)

Non ISO Operation

0 – CAN FD Frame format according to ISO 11898-1:2015

1 – CAN FD Frame format according to Bosch CAN FD
  Specification V1.0

/Sean

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] can: m_can: tcan4x5x: put the device out of standby before register access
  2019-12-09 19:24 [PATCH v2 1/2] can: m_can: tcan4x5x: put the device out of standby before register access Sean Nyekjaer
  2019-12-09 19:44 ` Marc Kleine-Budde
@ 2019-12-09 22:07 ` Marc Kleine-Budde
  2020-01-02 15:46 ` Marc Kleine-Budde
  2 siblings, 0 replies; 7+ messages in thread
From: Marc Kleine-Budde @ 2019-12-09 22:07 UTC (permalink / raw)
  To: Sean Nyekjaer, dmurphy, linux-can; +Cc: martin, stable


[-- Attachment #1.1: Type: text/plain, Size: 1832 bytes --]

On 12/9/19 8:24 PM, Sean Nyekjaer wrote:
> The m_can tries to detect of niso (canfd) is available while in standby,
> this function results in the following error:
> 
> tcan4x5x spi2.0 (unnamed net_device) (uninitialized): Failed to init module
> tcan4x5x spi2.0: m_can device registered (irq=84, version=32)
> tcan4x5x spi2.0 can2: TCAN4X5X successfully initialized.
> 
> When the tcan device comes out of reset it comes out in standby mode.
> The m_can driver tries to access the control register but fails due to
> the device is in standby mode.
> So this patch will put the tcan device in normal mode before the m_can
> driver does the initialization.
> 
> Fixes: 5443c226ba91 ("can: tcan4x5x: Add tcan4x5x driver to the kernel")
> Cc: stable@vger.kernel.org
> Signed-off-by: Sean Nyekjaer <sean@geanix.com>
> ---
> tcan4x5x_init will now be called from probe and the m_can call.
> Would it be better to move the mode switch only to the probe function?
> 
>  drivers/net/can/m_can/tcan4x5x.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/can/m_can/tcan4x5x.c b/drivers/net/can/m_can/tcan4x5x.c
> index 4e1789ea2bc3..3c30209ca84c 100644
> --- a/drivers/net/can/m_can/tcan4x5x.c
> +++ b/drivers/net/can/m_can/tcan4x5x.c
> @@ -455,6 +455,8 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
>  	if (ret)
>  		goto out_clk;
>  
> +	tcan4x5x_init(mcan_class);

add error handling

> +
>  	tcan4x5x_power_enable(priv->power, 1);
>  
>  	ret = m_can_class_register(mcan_class);
> 

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] can: m_can: tcan4x5x: put the device out of standby before register access
  2019-12-09 19:24 [PATCH v2 1/2] can: m_can: tcan4x5x: put the device out of standby before register access Sean Nyekjaer
  2019-12-09 19:44 ` Marc Kleine-Budde
  2019-12-09 22:07 ` Marc Kleine-Budde
@ 2020-01-02 15:46 ` Marc Kleine-Budde
  2020-01-02 16:09   ` Sean Nyekjaer
  2 siblings, 1 reply; 7+ messages in thread
From: Marc Kleine-Budde @ 2020-01-02 15:46 UTC (permalink / raw)
  To: Sean Nyekjaer, dmurphy, linux-can; +Cc: martin, stable


[-- Attachment #1.1: Type: text/plain, Size: 780 bytes --]

On 12/9/19 8:24 PM, Sean Nyekjaer wrote:
> The m_can tries to detect of niso (canfd) is available while in standby,
> this function results in the following error:
> 
> tcan4x5x spi2.0 (unnamed net_device) (uninitialized): Failed to init module
> tcan4x5x spi2.0: m_can device registered (irq=84, version=32)
> tcan4x5x spi2.0 can2: TCAN4X5X successfully initialized.

Can you add the missing error handling to m_can_config_endisable(), and
handle this error correctly in all its callers?

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] can: m_can: tcan4x5x: put the device out of standby before register access
  2020-01-02 15:46 ` Marc Kleine-Budde
@ 2020-01-02 16:09   ` Sean Nyekjaer
  2020-01-02 16:16     ` Marc Kleine-Budde
  0 siblings, 1 reply; 7+ messages in thread
From: Sean Nyekjaer @ 2020-01-02 16:09 UTC (permalink / raw)
  To: Marc Kleine-Budde, linux-can; +Cc: dmurphy, martin, stable



On 02/01/2020 16.46, Marc Kleine-Budde wrote:
> On 12/9/19 8:24 PM, Sean Nyekjaer wrote:
>> The m_can tries to detect of niso (canfd) is available while in standby,
>> this function results in the following error:
>>
>> tcan4x5x spi2.0 (unnamed net_device) (uninitialized): Failed to init module
>> tcan4x5x spi2.0: m_can device registered (irq=84, version=32)
>> tcan4x5x spi2.0 can2: TCAN4X5X successfully initialized.
> 
> Can you add the missing error handling to m_can_config_endisable(), and
> handle this error correctly in all its callers?
> 
> Marc
> 

Hi Marc

Sorry if this was a bit of mess :)
Version 6 of this patch is already applied....
https://www.spinics.net/lists/linux-can/msg03186.html

Do you want me to add more error handling than this?

/Sean

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] can: m_can: tcan4x5x: put the device out of standby before register access
  2020-01-02 16:09   ` Sean Nyekjaer
@ 2020-01-02 16:16     ` Marc Kleine-Budde
  0 siblings, 0 replies; 7+ messages in thread
From: Marc Kleine-Budde @ 2020-01-02 16:16 UTC (permalink / raw)
  To: Sean Nyekjaer, linux-can; +Cc: dmurphy, martin, stable


[-- Attachment #1.1: Type: text/plain, Size: 875 bytes --]

On 1/2/20 5:09 PM, Sean Nyekjaer wrote:
> Sorry if this was a bit of mess :)
> Version 6 of this patch is already applied....
> https://www.spinics.net/lists/linux-can/msg03186.html

I know, and I just send it out in a pull request. :D

> Do you want me to add more error handling than this?

So far I've no more comments, besides the ones I've send earlier today:

https://lkml.org/lkml/2020/1/2/197
https://lkml.org/lkml/2020/1/2/229
https://lkml.org/lkml/2020/1/2/296

If you want to contribute, please coordinate with Dan here. I think
we'll roll the changes via can-next.

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-01-02 16:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-09 19:24 [PATCH v2 1/2] can: m_can: tcan4x5x: put the device out of standby before register access Sean Nyekjaer
2019-12-09 19:44 ` Marc Kleine-Budde
2019-12-09 19:52   ` Sean Nyekjaer
2019-12-09 22:07 ` Marc Kleine-Budde
2020-01-02 15:46 ` Marc Kleine-Budde
2020-01-02 16:09   ` Sean Nyekjaer
2020-01-02 16:16     ` Marc Kleine-Budde

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.