Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3789244iog; Tue, 28 Jun 2022 02:51:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uMf8wzMXrhx48AdueT+nHTZeYAUYpMfydF/iBTQLFkZJkwMaCGx9eR1gUyj4tPHCZb6zJh X-Received: by 2002:a17:903:22c9:b0:16a:749b:16d6 with SMTP id y9-20020a17090322c900b0016a749b16d6mr2851342plg.32.1656409865764; Tue, 28 Jun 2022 02:51:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656409865; cv=none; d=google.com; s=arc-20160816; b=0wqLAhkG6ntfsU9sVBL5q/4UdGZcMLQgW/3D28FTgigSZyZt94WHsYCNsEZst3EiRv ehpD7TlILvJfHzQMBMKnIgMkXBUkmhASQd3zXwW4sPLu9YAGVecCIMtKszM861urdQcw IPDywHusr6IfdlDnzG9TIY0UIqAHSl3VumAC7Q1aSFWV422tDszt9pZ9cNCT00VhsJTZ +EhNamAcCjmVxYYuMoLD6macMW/RCdBFqesWrqO1p0eIJ/TviX6ZtMVlMg0NwwFNGFGX Hwmwk5oBmOGwVWj0q776eoSGOao9ffCvLYIaRCii1oWa+BvRrK2JJlaskoLa4k+kWv3P EjdA== 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=801n56RRF19njvd3sN05U/Pk8HphuQt6u550b7DOhRU=; b=Z2NKdynmf5M/3rKA2J5rKeH93c+tHCHM2Bg+vXZYEqd5cj8odf6WZImNSGyungTBC9 jca4m5tr9Q9eZDhBCqvLD1hIzAccK97tlk/+Y7nYsxW8GrgNZgFBNJelTzAohIprXpvf 9I9ANzMuiZbIwE/gcVVdWNpjBqnO9DgLeGdInKLn7NelvFkFGHTnDH38pFeamE2umoYW fJQzNX0SLPzFdWoIq46JyMlAoonL+vGtkrMaw023gaquZDQi9/oYo1MefLsw4vtomoK0 IzNrcEmA1xTye4sZj1RZdLwgA3HUklcdwx/xQ+k4gM+5+AQpt/N+Zpsv/NclZ3t2/x4g j0MQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Sfi0J69v; 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 e64-20020a636943000000b0040d1fc1bbdcsi18422218pgc.478.2022.06.28.02.50.52; Tue, 28 Jun 2022 02:51:05 -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=Sfi0J69v; 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 S1344553AbiF1Jtn (ORCPT + 99 others); Tue, 28 Jun 2022 05:49:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344543AbiF1JtE (ORCPT ); Tue, 28 Jun 2022 05:49:04 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 174232D1F7 for ; Tue, 28 Jun 2022 02:49:01 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id i18so21289305lfu.8 for ; Tue, 28 Jun 2022 02:49:01 -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=801n56RRF19njvd3sN05U/Pk8HphuQt6u550b7DOhRU=; b=Sfi0J69vaMPOEhNG6WtijHlldNNBSyYKnabmbOfatQmzjdbaXohnb9sm9+yIsihXvi QJ6SWz6Kek1j6cgGpPZjrhIwqFGVDwFz/nBlqGdA/jXJN2i6beXkwxUrk0LV2gvs2pPE mhM8qjY9dRRa5iwv6n0/36hybYgJBVcA10VCg= 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=801n56RRF19njvd3sN05U/Pk8HphuQt6u550b7DOhRU=; b=BnM8WkFDFgN87Y4FxAAzSuOcvvVtxsq60gPsyoii1llrpI95YvE4aR9hy2GvHDREit 7UBF9spwyMuPpnnRs3UFkHZfWAhmq6W08BDDfcHVifX5mEhug8kmgqU8MEF7jLh5znus 2YzMD+jUQjBr3GJtt5v0DH9L9doXn0X9cehVvzY2JOnQHdMdHAoaMIYJYi37bSw5yGdc o5CDqTHMVDbdwVSMAj3EFg8RQLFMXOs4PlKg9lH+/8KqKzLc7+O0MoeG6h0iPp6WjMMm UMQq24NxwEPErpxcB77OVcL3koTvMBThtbW0dFmSbUnn1zVe3LjTMtjmU3f/QhH/PJ0l 2B0Q== X-Gm-Message-State: AJIora+sMFV5ROLe1SbJSsZW3kTdOKfDEb8oyPWlzPyXyGhpLwgJzdrl tP+cUUXFP13eoW//pWRi0tR3qdwN3Z7qpV9mukRN1g== X-Received: by 2002:a05:6512:1192:b0:481:4ba:f14d with SMTP id g18-20020a056512119200b0048104baf14dmr10376899lfr.662.1656409739307; Tue, 28 Jun 2022 02:48:59 -0700 (PDT) MIME-Version: 1.0 References: <20220614122821.3646071-1-dario.binacchi@amarulasolutions.com> <20220614122821.3646071-6-dario.binacchi@amarulasolutions.com> <20220628092833.uo66jbnwhh5af6je@pengutronix.de> In-Reply-To: <20220628092833.uo66jbnwhh5af6je@pengutronix.de> From: Dario Binacchi Date: Tue, 28 Jun 2022 11:48:48 +0200 Message-ID: Subject: Re: [PATCH v4 05/12] can: slcan: use CAN network device driver API To: Marc Kleine-Budde Cc: linux-kernel@vger.kernel.org, Amarula patchwork , Oliver Hartkopp , michael@amarulasolutions.com, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , 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 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 Tue, Jun 28, 2022 at 11:28 AM Marc Kleine-Budde wrote: > > On 14.06.2022 14:28:14, Dario Binacchi wrote: > > As suggested by commit [1], now the driver uses the functions and the > > data structures provided by the CAN network device driver interface. > > > > Currently the driver doesn't implement a way to set bitrate for SLCAN > > based devices via ip tool, so you'll have to do this by slcand or > > slcan_attach invocation through the -sX parameter: > > > > - slcan_attach -f -s6 -o /dev/ttyACM0 > > - slcand -f -s8 -o /dev/ttyUSB0 > > > > where -s6 in will set adapter's bitrate to 500 Kbit/s and -s8 to > > 1Mbit/s. > > See the table below for further CAN bitrates: > > - s0 -> 10 Kbit/s > > - s1 -> 20 Kbit/s > > - s2 -> 50 Kbit/s > > - s3 -> 100 Kbit/s > > - s4 -> 125 Kbit/s > > - s5 -> 250 Kbit/s > > - s6 -> 500 Kbit/s > > - s7 -> 800 Kbit/s > > - s8 -> 1000 Kbit/s > > > > In doing so, the struct can_priv::bittiming.bitrate of the driver is not > > set and since the open_candev() checks that the bitrate has been set, it > > must be a non-zero value, the bitrate is set to a fake value (-1U) > > before it is called. > > > > The patch also changes the slcan_devs locking from rtnl to spin_lock. The > > change was tested with a kernel with the CONFIG_PROVE_LOCKING option > > enabled that did not show any errors. > > You're not allowed to call alloc_candev() with a spin_lock held. See > today's kernel test robot mail: > > | https://lore.kernel.org/all/YrpqO5jepAvv4zkf@xsang-OptiPlex-9020 > > I think it's best to keep the rtnl for now. The rtnl_lock() uses a mutex while I used a spin_lock. static DEFINE_MUTEX(rtnl_mutex); void rtnl_lock(void) { mutex_lock(&rtnl_mutex); } EXPORT_SYMBOL(rtnl_lock); So might it be worth trying with a mutex instead of rtnl_lock(), or do you think it is safer to return to rtn_lock () anyway? Thanks and regards, Dario > > regards, > 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