Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp202483iol; Thu, 9 Jun 2022 02:00:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyLiG0wnIA0EQ6Mo6Fumnmx57cFl8t3bYzaG3p275kHlOiv8aI0sBon3SV7wcbVbN63EqX X-Received: by 2002:a65:6e96:0:b0:3fd:c8b7:5fa6 with SMTP id bm22-20020a656e96000000b003fdc8b75fa6mr16490988pgb.569.1654765252789; Thu, 09 Jun 2022 02:00:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654765252; cv=none; d=google.com; s=arc-20160816; b=VladhySD7bW3xleHMITvHfeBJOEoVk8sTHo6QhsDvsChPRwnYCWFntuH2I/EEeA8fa 0WwYgv4KYEXJRVDK4uMzcxVSg3Y+8yZ/8bcA/OM86gxEIhoi9iec6zgWKuF/tkmBz4GE TfxfNiLov5+MDvqyPcUMY9gO5NZetWCEtvkYgHrWqBlKpeXw2nduUrg1EhvrO7KmD50R u/rHt4Rb5giQud3NMFuUDDZ8UJNYsqyI5CMWCupPtl/67qaqfH5IM/6x7zlCcEIK8cjR XV1cxxkw+JE7FWOkjjlxfw+j+s3Lwva45S8Fujzr/9VpstWjVK98B8Usg82JXhqS6cfl LiPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=AX9+sxGX0p4pOxpI6WHP+Cxv1wFDNrQZS5LsuLWat6c=; b=ghoHcEbqSEvSZCK3TdsotxvWG4+v/AOnHrJTrbUfZYix/OFBKzwQrO+phVe5+XxhN6 0i+B5vPVURcMOw9DZNFf7n77Tl1cZCdwl0e8HE/4AR8pzpx6djJvrxlby1HKKhuQsI4g WPIFh8dulrbYhJ9pD/bHayRMWx6bupojuFF4TIOolR7Sb9iZ1YGWd1D0KXqE4U3ch3R9 y4iMnbD49FSZ6tUD+1lCnC0v/aB3xuUUYC+7kBR65uRxG6CRdRX6YkA5uURpIAprzC/a d61RUbUKMRgL+bs86Ci0tfmplEAIs0NP/Kgc8t33WC5m/bV0dhFUS13tLQv+DszN8MyA DbMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=pjVfJTL0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a14-20020a17090abe0e00b001e3015b93absi27615378pjs.12.2022.06.09.02.00.37; Thu, 09 Jun 2022 02:00:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=pjVfJTL0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242710AbiFIIyh (ORCPT + 99 others); Thu, 9 Jun 2022 04:54:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242646AbiFIIyY (ORCPT ); Thu, 9 Jun 2022 04:54:24 -0400 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAFA16412 for ; Thu, 9 Jun 2022 01:52:15 -0700 (PDT) Received: by mail-lj1-x22f.google.com with SMTP id b12so14398660ljq.3 for ; Thu, 09 Jun 2022 01:52:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=AX9+sxGX0p4pOxpI6WHP+Cxv1wFDNrQZS5LsuLWat6c=; b=pjVfJTL0Wwdpk9HiOlKjTQg7bkwGj+pY84mbxzvjsLhVYXR6U8Rg2nPDuZ5HMH6v3J 3+P5k+4IJqQ+WQXgKtmb7vGsizWlSroLv6H3JP/F+mAC6VtRwB/gyffLMwfSXCWNSsX4 FKwLGPngTJnGsuDDl13f/LaGeEAPaQgqUrLpY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=AX9+sxGX0p4pOxpI6WHP+Cxv1wFDNrQZS5LsuLWat6c=; b=LoIq4XKwPNNp7LXt910H6469d5tzlNFkT6EPOwoGArVsF+nGZb8EvwD314APHgjgIc cQcFjFX002dD+opV1qo6d/2VcXX2eqHzm19wtJLHNEdu+XBfzku7qVefD9J2vjJPNJA+ ckeRCpZwC+xZ1ytnGGFBLBy0Tj0FIVo2xmprIKuN96TzTQclvWCiLFvlREFihUZfgh9G vu9uhe9iUoafyR+AqydJz8nXFOB0vvH8WeVF3s7aQKaJkxZ37MBDJ0Q8tfOSZOcm9eRX XRGiH6h0oRyRnXXjjHrh9O6HX3XCCREtx2Yja/4ZDiuoqlH4crHVh3UpWt7mxwnob2LW /bhg== X-Gm-Message-State: AOAM5308dMNnLhzt+mztiulLovs9y8vIhYepqDoyIq5MnOMWevraxBa+ +3YBcGQYc2Lk9DW6NHdAQj+NlttWOgqjiV5NKzC4eQ== X-Received: by 2002:a2e:6e0c:0:b0:255:98fb:cb45 with SMTP id j12-20020a2e6e0c000000b0025598fbcb45mr11214233ljc.55.1654764734145; Thu, 09 Jun 2022 01:52:14 -0700 (PDT) MIME-Version: 1.0 References: <20220607094752.1029295-1-dario.binacchi@amarulasolutions.com> <20220607094752.1029295-12-dario.binacchi@amarulasolutions.com> <20220607105225.xw33w32en7fd4vmh@pengutronix.de> <20220609063813.jf5u6iaghoae5dv3@pengutronix.de> <20220609080112.24bw2764ov767pqc@pengutronix.de> In-Reply-To: <20220609080112.24bw2764ov767pqc@pengutronix.de> From: Dario Binacchi Date: Thu, 9 Jun 2022 10:52:03 +0200 Message-ID: Subject: Re: [RFC PATCH 11/13] can: slcan: add ethtool support to reset adapter errors To: Marc Kleine-Budde Cc: linux-kernel@vger.kernel.org, Amarula patchwork , michael@amarulasolutions.com, "David S. Miller" , Eric Dumazet , Greg Kroah-Hartman , Jakub Kicinski , Jiri Slaby , Paolo Abeni , Sebastian Andrzej Siewior , Vincent Mailhol , Wolfgang Grandegger , linux-can@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Marc, On Thu, Jun 9, 2022 at 10:01 AM Marc Kleine-Budde wrote: > > On 09.06.2022 09:24:14, Dario Binacchi wrote: > > > > > I'm a big fan of bringing the device into a well known good state during > > > > > ifup. What would be the reasons/use cases to not reset the device? > > > > > > > > Because by default either slcand and slcan_attach don't reset the > > > > error states, but you must use the `-f' option to do so. So, I > > > > followed this use case. > > > > > > Is this a CAN bus error state, like Bus Off or some controller (i.e. non > > > CAN related) error? > > > > The help option of slcan_attach and slcand prints " -f (read status > > flags with 'F\\r' to reset error states)\n" I looked at the sources of > > the adapter I am using (USBtin, which uses the mcp2515 controller). > > The 'F' command reads the EFLG register (0x2d) without resetting the > > RX0OVR and RX1OVR overrun bits. > > The Lawicel doc [1] says 'F' is to read the status flags not to clear > it. However commit 7ef581fec029 ("slcan_attach: added '-f' commandline > option to read status flags") [2] suggests that there are some adapters > that the reading of the status flag clears the errors. IMHO the 'F' > command should be send unconditionally during open. When in doubt I would follow the slcand / slcan_attach approach, that don't send the 'F \ r' command by default. We would be more backward compatible as regards the sequence of commands to be sent to the controller. > > [1] http://www.can232.com/docs/can232_v3.pdf > [2] https://github.com/linux-can/can-utils/commit/7ef581fec0298a228baa71372ea5667874fb4a56 > > > The error states reset is done by 'f ' command, that is not > > managed by slcan_attach/slcand. > > Is the 'f' command is non-standard? It's possible. Thanks and regards, Dario > > > switch (subcmd) { > > case 0x0: // Disable status reporting > > mcp2515_write_register(MCP2515_REG_CANINTE, 0x00); > > return CR; > > case 0x1: // Enable status reporting > > mcp2515_write_register(MCP2515_REG_CANINTE, 0x20); // > > ERRIE interrupt to INT pin > > return CR; > > case 0x2: // Clear overrun errors > > mcp2515_write_register(MCP2515_REG_EFLG, 0x00); > > return CR; > > case 0x3: // Reinit/reset MCP2515 to clear all errors > > if (state == STATE_CONFIG) { > > mcp2515_init(); > > return CR; > > } > > break; > > } > > 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 | -- Dario Binacchi Embedded Linux Developer dario.binacchi@amarulasolutions.com __________________________________ Amarula Solutions SRL Via Le Canevare 30, 31100 Treviso, Veneto, IT T. +39 042 243 5310 info@amarulasolutions.com www.amarulasolutions.com