Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5137428yba; Wed, 10 Apr 2019 12:10:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwLSwwT47uNws+rvsIJb+nvPOn6wA+96cxpdzGs1rXQvD8ZgrqOM8Wx3qxKvj0CNqD4pgrX X-Received: by 2002:a63:6cc7:: with SMTP id h190mr43372365pgc.350.1554923448664; Wed, 10 Apr 2019 12:10:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554923448; cv=none; d=google.com; s=arc-20160816; b=gkR57k9U2oIyDjIOSnwXwyfvVJu5oZMpTwl+DEGzfg5f4OKUoDIuuiXqTLPY2WBzF7 RrceRdjCf71XkDk+sVuS4TLIIxqvUcp+sw55jjnvxTaZimOmpYrr03OwvPY3eggNDUV5 q6sUg2Thaivy/94N3a88e7wMlDDWB+NPpCsRFjSPIHUeDkntq7oxwLeAs9aUU1BQeBnA 1JJYpI6VWKpmumo1hPa0DHmvRoMfX9401nmK0PKgslp+Z29pJI5dw52/y+/Fx+RC/eqA PX1Fp12g6HtSTbX7mJZ7UfyzjMZL88GJlqhCszmS77s9jXDEDSOzho5RVhAZd0nTG9lM KHmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=5butOi9NeJl54vgWkLCY0TNlHUuyACb1dguvWmKvYCE=; b=b5jnPnEWe/7kYKv0g60zZLLreCYEd9qPsXmeowVPriMYn5yd3dvsdcd1DXbP8yisHc Z4R3R/tehcWHjupiExIehNijHfA2k0+BO2BVxo8AiG95YxhV20dge23wCOezxvS3LvCA bvpmFYtOFWi6enAkZN+MyxBJnFLBpud81AU0OivouYg0xSg16Gt4CtYyEHc3AwwU9UwN bMVxFy7Ive6L4u9rWCzSbPTyUE2I1yEU6JF0nBCPBCnwK2oEcolBaweSlLM+F9d16N7J X9My7LrNXf7zf31te5r17xLjpz1RYr5tXqB4BYPT2WL+BcuprEWbc5jSQGe57vh2AoQG r5Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@hartkopp.net header.s=strato-dkim-0002 header.b=ic5XYoir; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i63si6713755pli.195.2019.04.10.12.10.32; Wed, 10 Apr 2019 12:10:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@hartkopp.net header.s=strato-dkim-0002 header.b=ic5XYoir; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731399AbfDJSMG (ORCPT + 99 others); Wed, 10 Apr 2019 14:12:06 -0400 Received: from mo4-p01-ob.smtp.rzone.de ([85.215.255.53]:21531 "EHLO mo4-p01-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731183AbfDJSMG (ORCPT ); Wed, 10 Apr 2019 14:12:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1554919922; s=strato-dkim-0002; d=hartkopp.net; h=In-Reply-To:Date:Message-ID:From:References:Cc:To:Subject: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=5butOi9NeJl54vgWkLCY0TNlHUuyACb1dguvWmKvYCE=; b=ic5XYoira0/qu8O0/Ne/iw0ALpdA/0C7wbRfdaoQq2UJg0BCTwUyCzBbG/29CwZWE9 OQ7FSeNMad52p/qldFtQKzLfBZ3VdzQb05XKCsglZw+GE+hwMjc7S3xIW/hvD1qCBUcT 9C8b4FQ+j8zaDtXa9Anq2+hXL/4MgdBZFDWlVsOZF0TZ0g2dglC0DQURSIhka+tBpx7f h+MgNHJzdi+MaEKIy3k5Pc1Bzu7SMZfqpMUQ6mHpLCKaQIBYCyfCypA28Vv/khtHkkhY ONk3jGB4H+lDqwHI9Om9DFuFMpwGXlpsXu9Akc6rsj0yFWCNT/mKe3Rnc8gPwTHPeyf1 UvnQ== X-RZG-AUTH: ":P2MHfkW8eP4Mre39l357AZT/I7AY/7nT2yrDxb8mjG14FZxedJy6qgO1o3PMaViOoLMGUMh5mUuF" X-RZG-CLASS-ID: mo00 Received: from [192.168.1.200] by smtp.strato.de (RZmta 44.18 DYNA|AUTH) with ESMTPSA id q0b361v3AIBs6mL (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Wed, 10 Apr 2019 20:11:54 +0200 (CEST) Subject: Re: [PATCH] can: dev: clean up CAN ctrlmode when close CAN device To: Marc Kleine-Budde , Joakim Zhang , "wg@grandegger.com" , "davem@davemloft.net" Cc: dl-linux-imx , "linux-can@vger.kernel.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <20190410062533.31535-1-qiangqing.zhang@nxp.com> <39d8ef33-50c3-9b7a-88e1-8ef3a7fbac70@pengutronix.de> From: Oliver Hartkopp Message-ID: Date: Wed, 10 Apr 2019 20:11:49 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <39d8ef33-50c3-9b7a-88e1-8ef3a7fbac70@pengutronix.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >> --- >> 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 >