lkml.org 
[lkml]   [2019]   [Apr]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [EXT] Re: [PATCH] can: dev: clean up CAN ctrlmode when close CAN device
Date

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

\
 
 \ /
  Last update: 2019-04-11 03:18    [W:0.095 / U:0.832 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site