Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp743335imn; Tue, 26 Jul 2022 08:09:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vOPdsKMBritM4gArUx78E78JX7hfNhkuFb6nBKq4RLtqQEtZUxq+MLTuB63AmHO8U8FBJc X-Received: by 2002:a05:6a00:1395:b0:52b:7b04:af22 with SMTP id t21-20020a056a00139500b0052b7b04af22mr17703162pfg.8.1658848171524; Tue, 26 Jul 2022 08:09:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658848171; cv=none; d=google.com; s=arc-20160816; b=cgGkk/PtN7xOA/vmZpRUtt2v2WBsXiT4DHlxjls/NOzKHeEsRzIdKLkEbkiuEpUAQ4 wXufUd+85vawcuQ4Xl2jMBl/kb2ns+AScnKW3WBBuTpTgzCFXXG65975nqdJ55CLVmlr gxohhciN0/lNugzxkm4xg+g6JEKRRUb6U3El/aBRXk0m/K5AiamkWfOqSQ2hNgP9coTN ++IdcbE3PsaUZebZ7/qw9piL7fLOzSYPEUc09ZhnZf+tobz4+BTo0pbNDhM3e9o605iy o29TwiD5dbhDlxxQAyM1Mu3qglqsD82UDo1zAaJKGviDAtTPgKvQzSOdBJY6Ynetcfdo sX3Q== 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=n0HjOM/d2+hqNFb0LUzBClLdan9uRjh/1pepW+TXnpw=; b=sul/Mx9LYNLOb89oVppXpKbJHiXuCCBAmPjwZATfsEDRViaJdOP/3AYpOyEZOvsTHA 94Aye77jamKv1c4wiBlzqbLqSYWUBUkDI5OFG6nXoyn5LvtvHOkFEf3nbnoIf7pva0b0 LdhDjGf3VsY7VQpcilvKD4nf72Xqn0KAeYiHsAJJO+DHtTJHT4AhUTEN/P9s3bfoJuej rhBzBwW/qdLEhAzWukgkHw36d2kKnVykUJ0e/QpPIBvc741WsWwiRpPD+XDXz8p0uiXg yZaVt2HXpWOUTWThHo/sUxT3R4PfmFrSaP1CjlDDitkVjCTGg9cSslw+/7ab+q4ElxEL uTyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=mRMJjULN; 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 t9-20020a170902e84900b0016d6e8f5c42si8160513plg.543.2022.07.26.08.09.16; Tue, 26 Jul 2022 08:09:31 -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=mRMJjULN; 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 S239466AbiGZO73 (ORCPT + 99 others); Tue, 26 Jul 2022 10:59:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239431AbiGZO70 (ORCPT ); Tue, 26 Jul 2022 10:59:26 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B2A72CC98 for ; Tue, 26 Jul 2022 07:59:24 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id z25so23118686lfr.2 for ; Tue, 26 Jul 2022 07:59:24 -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=n0HjOM/d2+hqNFb0LUzBClLdan9uRjh/1pepW+TXnpw=; b=mRMJjULNmr1ZBAkPkI4xlsy1SUjQapLFdJNzkiWMYFeJMg7+A4HHMRuyX54Uq459Hn I2Aq5aTaF8MwK3dcOipuPuX3IWDr9R+MLjgH6hIdiCM69uDbuZ00q+TQ3PldgBYy8G7c OjkZ6OPf7zUadap6/teHx/KXbuiRJldpmFknY= 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=n0HjOM/d2+hqNFb0LUzBClLdan9uRjh/1pepW+TXnpw=; b=eddmEWSoQS9fzl+wjEMYXH47/oTqn/3fiOk3lb4DCYXiAFIP8iYNZGTmnX2ISJkqgI LGdz1MC6yf9snKjNB2g+xZyGLnHLfjzTzzbJT72qjPy1TyHZz5obyy8/eN4Ln2Csu9xv EZZV2D04QqhtoyhFfYJdwvi+4Z5T4vFenAMJUXHhlYfkEJA6KwexBLGG/TiLwDUxDAJw P3KUBBqToYYt5y75MnzDv9VeZZQfeD1wapO+plYyjCmWzLrjUaczc3h8kULNsiV/nrY1 wLW1vLkwhv5jnfhSC6UthZzUh3EcZFgPGp50724KloAmxP5hkBXgYxlerFBXSCi4Kvvq i8eA== X-Gm-Message-State: AJIora8mSUaC6/TTVBiNoF5tsyrLi8vXo5CrDjwZYZDIBWHNOIlD+cNr 2tKPoWrB+ltiFmjdld8fiCJrUwlJ0dAaXLlW9R332g== X-Received: by 2002:a05:6512:3c88:b0:48a:86d8:dbad with SMTP id h8-20020a0565123c8800b0048a86d8dbadmr4525794lfv.172.1658847562848; Tue, 26 Jul 2022 07:59:22 -0700 (PDT) MIME-Version: 1.0 References: <20220716170007.2020037-1-dario.binacchi@amarulasolutions.com> <20220716170007.2020037-3-dario.binacchi@amarulasolutions.com> <20220717233842.1451e349.max@enpas.org> <20220725150920.63ac3a77.max@enpas.org> In-Reply-To: <20220725150920.63ac3a77.max@enpas.org> From: Dario Binacchi Date: Tue, 26 Jul 2022 16:59:11 +0200 Message-ID: Subject: Re: [RFC PATCH 2/5] can: slcan: remove legacy infrastructure To: Max Staudt 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 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 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 Max, On Mon, Jul 25, 2022 at 3:09 PM Max Staudt wrote: > > 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 :) If possible I prefer not to use spin_lock. So I prefer to keep the code as is. Thanks and regards, Dario > > > Thank you! > > Max -- 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