Received: by 10.213.65.68 with SMTP id h4csp2838343imn; Mon, 9 Apr 2018 09:49:12 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/E9st8k6bSu3mvvONrcDJn7ULrUVGFVgNms8wf4EWbbIlKc9j+TJlxkjwQgk1NXYST4/MR X-Received: by 10.98.190.19 with SMTP id l19mr16855141pff.239.1523292552882; Mon, 09 Apr 2018 09:49:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523292552; cv=none; d=google.com; s=arc-20160816; b=wQi9ZTTsIo6gh6ZBBTTVqQ41aZm6+gzYEFiOlaUVou+pyJODR1SmcfdCaE2VPYO8kt Ye7M8t0L1oG9KDhMFwAJaG+MNdN/EAbdvMwrTXNZHkjfcgYGV4uYOtpqXWe8AYPCSdMm J3iQdCQMnQzjBohzixRSjE0mGSXIWU5E7CyXDkN1cSiTL4p5Qr8WzsSxO+At6LswAGmg Mz59Z4V/YMgcOJIj5WtOCP3w/EoovYtRuFVdN6h9NR/fcjn217v0itpdSUzwMvtQhwAz Eof3j2B1GvyGaDkyTR763xlvzIMXgu4aXVksRAJWcyUIeFgX5m81YZN15uTlkBQSyjfk dU0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:openpgp:from:references:cc:to:subject :arc-authentication-results; bh=4joedB/DURMxUQaaUzGPJp8321GvrutnzjRejz7sCW0=; b=GK5Dpq6r9ybDo2s6+o1TxdS6bxb8f6BTrf6WEFK59RGgo5BHqTUHk/dmz7sG10NcIV 1QnOK1qTNowswgBQWLfvQ4suySi/P1TRIgMdPUEtgGd1/l88OFx5sFoyQcKN4pTxhHtB BybH1UohGPXNAhm4zmy+OpPykX6lvTaOPt/0N+VyL8LPwwfOepx7iLXF7u6HJ78QHUM9 ItWlZdrPsWAPRXAwsjpdRRUkhIJyBTCKQH+7yXB01g2Petig45l3eTDLY5H9mZD/KF9P 0aAN44H9QDszLNXaxyhCHbXXvWDgsC3M7241e7Pv9ICbcZgSz1UlXEK14lR7gVEVhW5K TNQg== ARC-Authentication-Results: i=1; mx.google.com; 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 l91-v6si634332plb.301.2018.04.09.09.48.35; Mon, 09 Apr 2018 09:49:12 -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; 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 S1753643AbeDIQnc (ORCPT + 99 others); Mon, 9 Apr 2018 12:43:32 -0400 Received: from vegas.theobroma-systems.com ([144.76.126.164]:35718 "EHLO mail.theobroma-systems.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753612AbeDIQnb (ORCPT ); Mon, 9 Apr 2018 12:43:31 -0400 Received: from [86.59.122.178] (port=54251 helo=melshuber.lan) by mail.theobroma-systems.com with esmtpa (Exim 4.80) (envelope-from ) id 1f5ZtA-0005cp-FW; Mon, 09 Apr 2018 18:43:28 +0200 Subject: Re: [PATCH v4 1/1] can: ucan: add driver for Theobroma Systems UCAN devices To: Wolfgang Grandegger Cc: Jakob Unterwurzacher , Philipp Tomsich , Marc Kleine-Budde , linux-can@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180403143514.24200-1-jakob.unterwurzacher@theobroma-systems.com> <20180403143514.24200-2-jakob.unterwurzacher@theobroma-systems.com> From: Martin Elshuber Openpgp: preference=signencrypt Message-ID: Date: Mon, 9 Apr 2018 18:43:28 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hallo Wolfgang, thank you for the review, we have the update ready but we will test a while it before sending V5. Regarding your question on the firmware behavior, find the answer inline below. > Hello Jacob, > > just a few minor issues and a question about bus-off handling... > > Am 03.04.2018 um 16:35 schrieb Jakob Unterwurzacher: >> The UCAN driver supports the microcontroller-based USB/CAN >> adapters from Theobroma Systems. There are two form-factors >> that run essentially the same firmware: >> >> * Seal: standalone USB stick ( https://www.theobroma-systems.com/seal ) >> >> * Mule: integrated on the PCB of various System-on-Modules from >> Theobroma Systems like the A31-µQ7 and the RK3399-Q7 >> ( https://www.theobroma-systems.com/rk3399-q7 ) >> [..snip..] >> + >> + /* we switched into a worse state */ >> + up->can.state = new_state; >> + switch (new_state) { >> + case CAN_STATE_BUS_OFF: >> + can_stats->bus_off++; >> + can_bus_off(up->netdev); > How does the CAN controller firmware handle bus-off? Does it recover > automatically? "can_bus_off()" will restart the CAN controller after > "restart-ms" or manually via netlink "restart" command by calling > "ucan_set_mode(CAN_START_MODE)": > > # ip link set canX type can restart-ms 100 > # ip link set canX type can restart > > See also: > > https://elixir.bootlin.com/linux/latest/source/drivers/net/can/dev.c#L597 1) Once a bus-off condition is detected, the device sends an error    message do indicate the bus state change (the same happens    also for bus state changes into ERROR_ACTIVE/WARNING/PASSIVE). 2) The device will not restart the bus itself (to give application    control how to handle this event). 3) The device initiates a bus of recovery upon receiving the control    message UCAN_COMMAND_RESTART (see ucan_set_mode()) 4) The Linux CAN framework handles sending a CAN_ERR_RESTARTED message    and calling ucan_set_mode(). 5) Once the device completes the recovery, it sends a state change    message indicating that it is in ERROR_ACTIVE state (see 1). 6) During BUS-OFF no error frames or normal frames are set from the    device to the host. 7) If the device receives a frame from the host when in bus-off (e.g.:    just after detecting the condition) the device confirms reception by    sending an TX_COMPLETE with and error indicator and drops the frame.    Finally the driver calls can_free_echo_skb() upon reception of the    TX_COMPLETE message (see ucan_tx_complete_msg()). The protocol documentation will be updated accordingly [..snip..] > Thanks for your contribution! > > Wolfgang. > Best regards Martin -- Martin Elshuber Theobroma Systems Design und Consulting GmbH Seestadtstraße 27 (Aspern IQ), 1220 Wien, Austria Phone: +43 1 236 98 93-405, Fax: +43 1 236 98 93-9 http://www.theobroma-systems.com