Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp2707910imi; Mon, 25 Jul 2022 06:19:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vc8wzVjd7qlBMKk+pw0MAXWhuZVRzz1+VC1f0OXom1EUDFWhiEwHRJVpQArjgJKxIqTQXv X-Received: by 2002:a62:ee01:0:b0:52b:bfb3:6fe8 with SMTP id e1-20020a62ee01000000b0052bbfb36fe8mr12933111pfi.28.1658755176513; Mon, 25 Jul 2022 06:19:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658755176; cv=none; d=google.com; s=arc-20160816; b=p2WP++ZUohJPSTSxeJg5FMFkDkWiPDePeUXcxqJMe4+fXgZW5FeQaHOAlSpuf9rePV Lze7dpsrywgjkP/vnxY4T3c57cZFSp89u8ByM3F6bq/fOMAZzdLJmXhN9821Smz1azMp vUw4WVpjkJ8XtFUVHTw+fFaFIMA31uIwmy+smf6pjOf1oAWlj85jbOWBBgDql1mRYt2P CbvloThlP42ieUvPFYGTu8uSYceP/rDa4hCseX+d592ff3LEktBxNWam2ZhMhxyc/Uee 2ruTkr5IowMZ6yRNwU82fqzqUxKspwZtpINudrduE+gV2A3bbGloN2QDHfXd4dxfYZ9S 7qmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=h7eFFipxcjQcq6fPjpQfgdILYZFfhZ/GQSMNgQsu+6g=; b=SAIT65ieJzAVf/LtpbDSjJVDIUm12h9Aqvxh1xZpEb6xpINiVKwg7JRGWy6XvGhOk4 Q2Eh9WAmq9so6MrnB7dYV611U1My/3tRstc8kkKEiTNEE906UwmFbtL1u84qHMWpSv3s fuFqHmjP+JrgW1SQhtbLBRQcJEeQ/9h59J5g4ARInHQxLQKvb57/EF2jmqvfS68uRI5v wj4zhpq6Q8SmkW/b/4O5vF/Rv2ffI421BJ7SSixcKN7+Jmv56ItexUpE43hIY2fS/+VF eaCrbgvYQGyFjXJUoACcuHHaTgPSFoxg4/wydiN0sEX1nfba+/XPXgxuDM7LCsCeF/bW WwNg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y11-20020a17090aa40b00b001f14535e904si16768291pjp.147.2022.07.25.06.19.21; Mon, 25 Jul 2022 06:19:36 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235499AbiGYNJf (ORCPT + 99 others); Mon, 25 Jul 2022 09:09:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235481AbiGYNJc (ORCPT ); Mon, 25 Jul 2022 09:09:32 -0400 Received: from mail.enpas.org (zhong.enpas.org [46.38.239.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 22AF013D76; Mon, 25 Jul 2022 06:09:28 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail.enpas.org (Postfix) with ESMTPSA id 430C0FF9C3; Mon, 25 Jul 2022 13:09:26 +0000 (UTC) Date: Mon, 25 Jul 2022 15:09:20 +0200 From: Max Staudt To: Dario Binacchi Cc: linux-kernel@vger.kernel.org, Jeroen Hofstee , michael@amarulasolutions.com, Amarula patchwork , "David S. Miller" , Eric Dumazet , Greg Kroah-Hartman , Jakub Kicinski , Jiri Slaby , Marc Kleine-Budde , Paolo Abeni , Vincent Mailhol , Wolfgang Grandegger , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [RFC PATCH 2/5] can: slcan: remove legacy infrastructure Message-ID: <20220725150920.63ac3a77.max@enpas.org> In-Reply-To: References: <20220716170007.2020037-1-dario.binacchi@amarulasolutions.com> <20220716170007.2020037-3-dario.binacchi@amarulasolutions.com> <20220717233842.1451e349.max@enpas.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham 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 On Mon, 25 Jul 2022 08:40:24 +0200 Dario Binacchi wrote: > > > @@ -883,72 +786,50 @@ static int slcan_open(struct tty_struct *tty) > > > if (!tty->ops->write) > > > return -EOPNOTSUPP; > > > > > > - /* RTnetlink lock is misused here to serialize concurrent > > > - * opens of slcan channels. There are better ways, but it is > > > - * the simplest one. > > > - */ > > > - rtnl_lock(); > > > + dev = alloc_candev(sizeof(*sl), 1); > > > + if (!dev) > > > + return -ENFILE; > > > > > > - /* Collect hanged up channels. */ > > > - slc_sync(); > > > + sl = netdev_priv(dev); > > > > > > - sl = tty->disc_data; > > > + /* Configure TTY interface */ > > > + tty->receive_room = 65536; /* We don't flow control */ > > > + sl->rcount = 0; > > > + sl->xleft = 0; > > > > I suggest moving the zeroing to slc_open() - i.e. to the netdev open > > function. As a bonus, you can then remove the same two assignments from > > slc_close() (see above). They are only used when netif_running(), with > > appropiate guards already in place as far as I can see. > > I think it is better to keep the code as it is, since at the entry of > the netdev > open function, netif_running already returns true (it is set to true by the > calling function) and therefore it would be less safe to reset the > rcount and xleft > fields. Wow, great catch! I wonder why __LINK_STATE_START is set before ->ndo_open() is called...? Since the drivers are similar, I've checked can327. It is unaffected, because the counters are additionally guarded by a spinlock. Same in slcan, where netdev_close() takes the spinlock to reset the counters. So you *could* move them to netdev_open() *if* they are always guarded by the slcan lock. Or, leave it as it is, as it seems to be correct. Your choice :) Thank you! Max