linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] can: dev: clean up CAN ctrlmode when close CAN device
@ 2019-04-10  6:27 Joakim Zhang
  2019-04-10  7:19 ` Marc Kleine-Budde
  0 siblings, 1 reply; 8+ messages in thread
From: Joakim Zhang @ 2019-04-10  6:27 UTC (permalink / raw)
  To: wg, mkl, davem
  Cc: dl-linux-imx, linux-can, netdev, linux-kernel, Joakim Zhang

CAN driver always writes registers according to "ctrlmode", and now CAN
framework will keep CAN ctrlmode after device closed.

e.g. with following sequences:
1)ip link set can0 type can bitrate 1000000 loopback on
2)ip link set can0 up
3)ip link set can0 down
4)ip link set can0 type can bitrate 1000000
5)ip link set can0 up

After this sequence, we may want to test loopback for the first time and
not to test loopback second time. However, CAN device still keep
"ctrlmode" as loopback on.

This patch intends to clean up CAN ctrlmode when close CAN device. We
can set which ctrlmode we need when open CAN device again.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
---
 drivers/net/can/dev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index c05e4d50d43d..4f69a8f16ba3 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -870,6 +870,7 @@ void close_candev(struct net_device *dev)
 	struct can_priv *priv = netdev_priv(dev);
 
 	cancel_delayed_work_sync(&priv->restart_work);
+	priv->ctrlmode = 0;
 	can_flush_echo_skb(dev);
 }
 EXPORT_SYMBOL_GPL(close_candev);
-- 
2.17.1


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

* Re: [PATCH] can: dev: clean up CAN ctrlmode when close CAN device
  2019-04-10  6:27 [PATCH] can: dev: clean up CAN ctrlmode when close CAN device Joakim Zhang
@ 2019-04-10  7:19 ` Marc Kleine-Budde
  2019-04-10  7:55   ` [EXT] " Joakim Zhang
  2019-04-10 18:11   ` Oliver Hartkopp
  0 siblings, 2 replies; 8+ messages in thread
From: Marc Kleine-Budde @ 2019-04-10  7:19 UTC (permalink / raw)
  To: Joakim Zhang, wg, davem; +Cc: dl-linux-imx, linux-can, netdev, linux-kernel


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

On 4/10/19 8:27 AM, Joakim Zhang wrote:
> CAN driver always writes registers according to "ctrlmode", and now CAN
> framework will keep CAN ctrlmode after device closed.
> 
> e.g. with following sequences:
> 1)ip link set can0 type can bitrate 1000000 loopback on
> 2)ip link set can0 up
> 3)ip link set can0 down
> 4)ip link set can0 type can bitrate 1000000
> 5)ip link set can0 up
> 
> After this sequence, we may want to test loopback for the first time and
> not to test loopback second time. However, CAN device still keep
> "ctrlmode" as loopback on.

Then you should configure loopback off in userspace.

> This patch intends to clean up CAN ctrlmode when close CAN device. We
> can set which ctrlmode we need when open CAN device again.

Consider a CANFD device, where CANFD has been enabled. It will feel very
weird if the interface looses the CANFD property by just a ifdown; ifup.

> 
> Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
> ---
>  drivers/net/can/dev.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
> index c05e4d50d43d..4f69a8f16ba3 100644
> --- a/drivers/net/can/dev.c
> +++ b/drivers/net/can/dev.c
> @@ -870,6 +870,7 @@ void close_candev(struct net_device *dev)
>  	struct can_priv *priv = netdev_priv(dev);
>  
>  	cancel_delayed_work_sync(&priv->restart_work);
> +	priv->ctrlmode = 0;
>  	can_flush_echo_skb(dev);
>  }
>  EXPORT_SYMBOL_GPL(close_candev);
> 

Marc

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


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

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

* RE: [EXT] Re: [PATCH] can: dev: clean up CAN ctrlmode when close CAN device
  2019-04-10  7:19 ` Marc Kleine-Budde
@ 2019-04-10  7:55   ` Joakim Zhang
  2019-04-10 17:49     ` Marc Kleine-Budde
  2019-04-10 18:11   ` Oliver Hartkopp
  1 sibling, 1 reply; 8+ messages in thread
From: Joakim Zhang @ 2019-04-10  7:55 UTC (permalink / raw)
  To: Marc Kleine-Budde, wg, davem
  Cc: dl-linux-imx, linux-can, netdev, linux-kernel


> -----Original Message-----
> From: Marc Kleine-Budde <mkl@pengutronix.de>
> Sent: 2019年4月10日 15:19
> To: Joakim Zhang <qiangqing.zhang@nxp.com>; wg@grandegger.com;
> davem@davemloft.net
> Cc: dl-linux-imx <linux-imx@nxp.com>; linux-can@vger.kernel.org;
> netdev@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: [EXT] Re: [PATCH] can: dev: clean up CAN ctrlmode when close CAN
> device
> 
> On 4/10/19 8:27 AM, Joakim Zhang wrote:
> > CAN driver always writes registers according to "ctrlmode", and now
> > CAN framework will keep CAN ctrlmode after device closed.
> >
> > e.g. with following sequences:
> > 1)ip link set can0 type can bitrate 1000000 loopback on 2)ip link set
> > can0 up 3)ip link set can0 down 4)ip link set can0 type can bitrate
> > 1000000 5)ip link set can0 up
> >
> > After this sequence, we may want to test loopback for the first time
> > and not to test loopback second time. However, CAN device still keep
> > "ctrlmode" as loopback on.
> 
> Then you should configure loopback off in userspace.

 Got it. Thank you.

> > This patch intends to clean up CAN ctrlmode when close CAN device. We
> > can set which ctrlmode we need when open CAN device again.
> 
> Consider a CANFD device, where CANFD has been enabled. It will feel very
> weird if the interface looses the CANFD property by just a ifdown; ifup.

Yes, you are right. But fd mode should compatible with normal can. When I want to switch to normal can from fd mode.
You mean that we should configure fd off in userspace as we may write some specific registers only by fd mode?


Best Regards,
Joakim Zhang
> >
> > Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
> > ---
> >  drivers/net/can/dev.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c index
> > c05e4d50d43d..4f69a8f16ba3 100644
> > --- a/drivers/net/can/dev.c
> > +++ b/drivers/net/can/dev.c
> > @@ -870,6 +870,7 @@ void close_candev(struct net_device *dev)
> >  	struct can_priv *priv = netdev_priv(dev);
> >
> >  	cancel_delayed_work_sync(&priv->restart_work);
> > +	priv->ctrlmode = 0;
> >  	can_flush_echo_skb(dev);
> >  }
> >  EXPORT_SYMBOL_GPL(close_candev);
> >
> 
> Marc
> 
> --
> Pengutronix e.K.                  | Marc Kleine-Budde           |
> Industrial Linux Solutions        | Phone: +49-231-2826-924     |
> Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
> Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


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

* Re: [EXT] Re: [PATCH] can: dev: clean up CAN ctrlmode when close CAN device
  2019-04-10  7:55   ` [EXT] " Joakim Zhang
@ 2019-04-10 17:49     ` Marc Kleine-Budde
  2019-04-11  1:16       ` Joakim Zhang
  0 siblings, 1 reply; 8+ messages in thread
From: Marc Kleine-Budde @ 2019-04-10 17:49 UTC (permalink / raw)
  To: Joakim Zhang, wg, davem; +Cc: dl-linux-imx, linux-can, netdev, linux-kernel


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

On 4/10/19 9:55 AM, Joakim Zhang wrote:
> 
>> -----Original Message-----
>> From: Marc Kleine-Budde <mkl@pengutronix.de>
>> Sent: 2019年4月10日 15:19
>> To: Joakim Zhang <qiangqing.zhang@nxp.com>; wg@grandegger.com;
>> davem@davemloft.net
>> Cc: dl-linux-imx <linux-imx@nxp.com>; linux-can@vger.kernel.org;
>> netdev@vger.kernel.org; linux-kernel@vger.kernel.org
>> Subject: [EXT] Re: [PATCH] can: dev: clean up CAN ctrlmode when close CAN
>> device
>>
>> On 4/10/19 8:27 AM, Joakim Zhang wrote:
>>> CAN driver always writes registers according to "ctrlmode", and now
>>> CAN framework will keep CAN ctrlmode after device closed.
>>>
>>> e.g. with following sequences:
>>> 1)ip link set can0 type can bitrate 1000000 loopback on 2)ip link set
>>> can0 up 3)ip link set can0 down 4)ip link set can0 type can bitrate
>>> 1000000 5)ip link set can0 up
>>>
>>> After this sequence, we may want to test loopback for the first time
>>> and not to test loopback second time. However, CAN device still keep
>>> "ctrlmode" as loopback on.
>>
>> Then you should configure loopback off in userspace.
> 
>  Got it. Thank you.
> 
>>> This patch intends to clean up CAN ctrlmode when close CAN device. We
>>> can set which ctrlmode we need when open CAN device again.
>>
>> Consider a CANFD device, where CANFD has been enabled. It will feel very
>> weird if the interface looses the CANFD property by just a ifdown; ifup.
> 
> Yes, you are right. But fd mode should compatible with normal can.

CANFD was just an example. Take CAN_CTRLMODE_ONE_SHOT as another
example. You don't want your network device settings to vanish if you
switch the interface off and on again.

> When I want to switch to normal can from fd mode. You mean that we
> should configure fd off in userspace as we may write some specific
> registers only by fd mode?

Whatever mode you enable via user space use user space to disable them
again.

Marc

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


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

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

* Re: [PATCH] can: dev: clean up CAN ctrlmode when close CAN device
  2019-04-10  7:19 ` Marc Kleine-Budde
  2019-04-10  7:55   ` [EXT] " Joakim Zhang
@ 2019-04-10 18:11   ` Oliver Hartkopp
  1 sibling, 0 replies; 8+ messages in thread
From: Oliver Hartkopp @ 2019-04-10 18:11 UTC (permalink / raw)
  To: Marc Kleine-Budde, Joakim Zhang, wg, davem
  Cc: dl-linux-imx, linux-can, netdev, linux-kernel



On 10.04.19 09:19, Marc Kleine-Budde wrote:
> On 4/10/19 8:27 AM, Joakim Zhang wrote:
>> CAN driver always writes registers according to "ctrlmode", and now CAN
>> framework will keep CAN ctrlmode after device closed.
>>
>> e.g. with following sequences:
>> 1)ip link set can0 type can bitrate 1000000 loopback on
>> 2)ip link set can0 up
>> 3)ip link set can0 down
>> 4)ip link set can0 type can bitrate 1000000
>> 5)ip link set can0 up
>>
>> After this sequence, we may want to test loopback for the first time and
>> not to test loopback second time. However, CAN device still keep
>> "ctrlmode" as loopback on.
> 
> Then you should configure loopback off in userspace.

ACK!

The idea is that you can set a CAN interface like this:

ip link set can0 type can bitrate 1000000 loopback on

(..)

ip link set can0 down
ip link set can0 up

and none of the configuration changes in the meanwhile.

Regards,
Oliver

> 
>> This patch intends to clean up CAN ctrlmode when close CAN device. We
>> can set which ctrlmode we need when open CAN device again.
> 
> Consider a CANFD device, where CANFD has been enabled. It will feel very
> weird if the interface looses the CANFD property by just a ifdown; ifup.
> 
>>
>> Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
>> ---
>>   drivers/net/can/dev.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
>> index c05e4d50d43d..4f69a8f16ba3 100644
>> --- a/drivers/net/can/dev.c
>> +++ b/drivers/net/can/dev.c
>> @@ -870,6 +870,7 @@ void close_candev(struct net_device *dev)
>>   	struct can_priv *priv = netdev_priv(dev);
>>   
>>   	cancel_delayed_work_sync(&priv->restart_work);
>> +	priv->ctrlmode = 0;
>>   	can_flush_echo_skb(dev);
>>   }
>>   EXPORT_SYMBOL_GPL(close_candev);
>>
> 
> Marc
> 

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

* RE: [EXT] Re: [PATCH] can: dev: clean up CAN ctrlmode when close CAN device
  2019-04-10 17:49     ` Marc Kleine-Budde
@ 2019-04-11  1:16       ` Joakim Zhang
  2019-04-11  6:38         ` Marc Kleine-Budde
  0 siblings, 1 reply; 8+ messages in thread
From: Joakim Zhang @ 2019-04-11  1:16 UTC (permalink / raw)
  To: Marc Kleine-Budde, wg, davem
  Cc: dl-linux-imx, linux-can, netdev, linux-kernel


> -----Original Message-----
> From: Marc Kleine-Budde <mkl@pengutronix.de>
> Sent: 2019年4月11日 1:50
> To: Joakim Zhang <qiangqing.zhang@nxp.com>; wg@grandegger.com;
> davem@davemloft.net
> Cc: dl-linux-imx <linux-imx@nxp.com>; linux-can@vger.kernel.org;
> netdev@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [EXT] Re: [PATCH] can: dev: clean up CAN ctrlmode when close
> CAN device
> 
> On 4/10/19 9:55 AM, Joakim Zhang wrote:
> >
> >> -----Original Message-----
> >> From: Marc Kleine-Budde <mkl@pengutronix.de>
> >> Sent: 2019年4月10日 15:19
> >> To: Joakim Zhang <qiangqing.zhang@nxp.com>; wg@grandegger.com;
> >> davem@davemloft.net
> >> Cc: dl-linux-imx <linux-imx@nxp.com>; linux-can@vger.kernel.org;
> >> netdev@vger.kernel.org; linux-kernel@vger.kernel.org
> >> Subject: [EXT] Re: [PATCH] can: dev: clean up CAN ctrlmode when close
> >> CAN device
> >>
> >> On 4/10/19 8:27 AM, Joakim Zhang wrote:
> >>> CAN driver always writes registers according to "ctrlmode", and now
> >>> CAN framework will keep CAN ctrlmode after device closed.
> >>>
> >>> e.g. with following sequences:
> >>> 1)ip link set can0 type can bitrate 1000000 loopback on 2)ip link
> >>> set
> >>> can0 up 3)ip link set can0 down 4)ip link set can0 type can bitrate
> >>> 1000000 5)ip link set can0 up
> >>>
> >>> After this sequence, we may want to test loopback for the first time
> >>> and not to test loopback second time. However, CAN device still keep
> >>> "ctrlmode" as loopback on.
> >>
> >> Then you should configure loopback off in userspace.
> >
> >  Got it. Thank you.
> >
> >>> This patch intends to clean up CAN ctrlmode when close CAN device.
> >>> We can set which ctrlmode we need when open CAN device again.
> >>
> >> Consider a CANFD device, where CANFD has been enabled. It will feel
> >> very weird if the interface looses the CANFD property by just a ifdown; ifup.
> >
> > Yes, you are right. But fd mode should compatible with normal can.
> 
> CANFD was just an example. Take CAN_CTRLMODE_ONE_SHOT as another
> example. You don't want your network device settings to vanish if you switch
> the interface off and on again.
> 
> > When I want to switch to normal can from fd mode. You mean that we
> > should configure fd off in userspace as we may write some specific
> > registers only by fd mode?
> 
> Whatever mode you enable via user space use user space to disable them
> again.

Thank you for your detailed explanation. But in flexcan driver, it just set register bit when mode on and do not clear
register bit when mode off, e.g. loopback, listennoly, 3 samples....
When we configure mode off after configured mode on in the user space, corresponding bit will not change. Is this should be improved in flexcan driver?
 
Best Regards,
Joakim Zhang
> Marc
> 
> --
> Pengutronix e.K.                  | Marc Kleine-Budde           |
> Industrial Linux Solutions        | Phone: +49-231-2826-924     |
> Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
> Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


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

* Re: [EXT] Re: [PATCH] can: dev: clean up CAN ctrlmode when close CAN device
  2019-04-11  1:16       ` Joakim Zhang
@ 2019-04-11  6:38         ` Marc Kleine-Budde
  2019-04-11  8:12           ` Joakim Zhang
  0 siblings, 1 reply; 8+ messages in thread
From: Marc Kleine-Budde @ 2019-04-11  6:38 UTC (permalink / raw)
  To: Joakim Zhang, wg, davem; +Cc: dl-linux-imx, linux-can, netdev, linux-kernel


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

On 4/11/19 3:16 AM, Joakim Zhang wrote:
>> Whatever mode you enable via user space use user space to disable them
>> again.
> 
> Thank you for your detailed explanation. But in flexcan driver, it
> just set register bit when mode on and do not clear register bit when
> mode off, e.g. loopback, listennoly, 3 samples....

Let's see:

> 	reg = priv->read(&regs->ctrl);

The ctrl reg is read

> 	reg &= ~(FLEXCAN_CTRL_PRESDIV(0xff) |
> 		 FLEXCAN_CTRL_RJW(0x3) |
> 		 FLEXCAN_CTRL_PSEG1(0x7) |
> 		 FLEXCAN_CTRL_PSEG2(0x7) |
> 		 FLEXCAN_CTRL_PROPSEG(0x7) |
> 		 FLEXCAN_CTRL_LPB |
> 		 FLEXCAN_CTRL_SMP |
> 		 FLEXCAN_CTRL_LOM);

....the loopback mode, 3 sample mode and listen only mode bits are
masked out....

> 	reg |= FLEXCAN_CTRL_PRESDIV(bt->brp - 1) |
> 		FLEXCAN_CTRL_PSEG1(bt->phase_seg1 - 1) |
> 		FLEXCAN_CTRL_PSEG2(bt->phase_seg2 - 1) |
> 		FLEXCAN_CTRL_RJW(bt->sjw - 1) |
> 		FLEXCAN_CTRL_PROPSEG(bt->prop_seg - 1);
> 
> 	if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK)
> 		reg |= FLEXCAN_CTRL_LPB;
> 	if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)
> 		reg |= FLEXCAN_CTRL_LOM;
> 	if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES)
> 		reg |= FLEXCAN_CTRL_SMP;

...and the bits are set, if enabled by user space...

> 	netdev_dbg(dev, "writing ctrl=0x%08x\n", reg);
> 	priv->write(reg, &regs->ctrl);

...and written to the register.

So all three bits will be unset, if unset by user space, right?

> When we configure mode off after configured mode on in the user
> space, corresponding bit will not change. Is this should be improved
> in flexcan driver?

That should work. If it doesn't work, we need a fix.

regards,
Marc

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


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

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

* RE: [EXT] Re: [PATCH] can: dev: clean up CAN ctrlmode when close CAN device
  2019-04-11  6:38         ` Marc Kleine-Budde
@ 2019-04-11  8:12           ` Joakim Zhang
  0 siblings, 0 replies; 8+ messages in thread
From: Joakim Zhang @ 2019-04-11  8:12 UTC (permalink / raw)
  To: Marc Kleine-Budde, wg, davem
  Cc: dl-linux-imx, linux-can, netdev, linux-kernel


> -----Original Message-----
> From: Marc Kleine-Budde <mkl@pengutronix.de>
> Sent: 2019年4月11日 14:39
> To: Joakim Zhang <qiangqing.zhang@nxp.com>; wg@grandegger.com;
> davem@davemloft.net
> Cc: dl-linux-imx <linux-imx@nxp.com>; linux-can@vger.kernel.org;
> netdev@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [EXT] Re: [PATCH] can: dev: clean up CAN ctrlmode when close
> CAN device
> 
> On 4/11/19 3:16 AM, Joakim Zhang wrote:
> >> Whatever mode you enable via user space use user space to disable
> >> them again.
> >
> > Thank you for your detailed explanation. But in flexcan driver, it
> > just set register bit when mode on and do not clear register bit when
> > mode off, e.g. loopback, listennoly, 3 samples....
> 
> Let's see:
> 
> > 	reg = priv->read(&regs->ctrl);
> 
> The ctrl reg is read
> 
> > 	reg &= ~(FLEXCAN_CTRL_PRESDIV(0xff) |
> > 		 FLEXCAN_CTRL_RJW(0x3) |
> > 		 FLEXCAN_CTRL_PSEG1(0x7) |
> > 		 FLEXCAN_CTRL_PSEG2(0x7) |
> > 		 FLEXCAN_CTRL_PROPSEG(0x7) |
> > 		 FLEXCAN_CTRL_LPB |
> > 		 FLEXCAN_CTRL_SMP |
> > 		 FLEXCAN_CTRL_LOM);
> 
> ....the loopback mode, 3 sample mode and listen only mode bits are masked
> out....
> 
> > 	reg |= FLEXCAN_CTRL_PRESDIV(bt->brp - 1) |
> > 		FLEXCAN_CTRL_PSEG1(bt->phase_seg1 - 1) |
> > 		FLEXCAN_CTRL_PSEG2(bt->phase_seg2 - 1) |
> > 		FLEXCAN_CTRL_RJW(bt->sjw - 1) |
> > 		FLEXCAN_CTRL_PROPSEG(bt->prop_seg - 1);
> >
> > 	if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK)
> > 		reg |= FLEXCAN_CTRL_LPB;
> > 	if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)
> > 		reg |= FLEXCAN_CTRL_LOM;
> > 	if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES)
> > 		reg |= FLEXCAN_CTRL_SMP;
> 
> ...and the bits are set, if enabled by user space...
> 
> > 	netdev_dbg(dev, "writing ctrl=0x%08x\n", reg);
> > 	priv->write(reg, &regs->ctrl);
> 
> ...and written to the register.
> 
> So all three bits will be unset, if unset by user space, right?

Oh, I see. Thank you!

Best Regards,
Joakim Zhang
> 
> > When we configure mode off after configured mode on in the user space,
> > corresponding bit will not change. Is this should be improved in
> > flexcan driver?
> 
> That should work. If it doesn't work, we need a fix.
> 
> regards,
> Marc
> 
> --
> Pengutronix e.K.                  | Marc Kleine-Budde           |
> Industrial Linux Solutions        | Phone: +49-231-2826-924     |
> Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
> Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


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

end of thread, other threads:[~2019-04-11  8:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-10  6:27 [PATCH] can: dev: clean up CAN ctrlmode when close CAN device Joakim Zhang
2019-04-10  7:19 ` Marc Kleine-Budde
2019-04-10  7:55   ` [EXT] " Joakim Zhang
2019-04-10 17:49     ` Marc Kleine-Budde
2019-04-11  1:16       ` Joakim Zhang
2019-04-11  6:38         ` Marc Kleine-Budde
2019-04-11  8:12           ` Joakim Zhang
2019-04-10 18:11   ` Oliver Hartkopp

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).