Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3828440iog; Tue, 28 Jun 2022 03:44:53 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sl8fkEWfn/tUzsDwzjx+/AqDtjbQrLwXCVvBXcQ/ZLhPF9IPIPpGpRXuFmwW83b1izfHfF X-Received: by 2002:a17:90a:5309:b0:1ec:82a1:3b86 with SMTP id x9-20020a17090a530900b001ec82a13b86mr20972584pjh.54.1656413092900; Tue, 28 Jun 2022 03:44:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656413092; cv=none; d=google.com; s=arc-20160816; b=p2XD/jDaTr/ymIyuinQzQO9ilHONgjgqWGnIId6HEhHMnRF7AV0/Q2knPc0UOUuuGe ZE7X67Dk16MjO5IWlnfo/F9aI6zdCcHvAHALEemfli8E0NWA0n/3glXI9LYE8S5zfvH0 UKC5Ie2hiPU+gl5T108NUZcB4OA8j29MrzdIR4MzYiIuE2gQPgz+J3uRA88YHjIERcM9 F0sD84VouZVHf7UST6b4A1+5fkH/jozaf3QzWepJxaquW4LjIdORRa4OtDXXlY+3JYFm JUFjXRlVHYCO6jTpNKs4c/jO6oD5Y5f+Xe230i9BBPkcgy3HDx1xXEz8PCkw1R/usEyQ rEIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=f6hl4NbdEt0ifnOvhOKpBRW5NYe3UYI6VJOmtthI/10=; b=tPKV1cyzjPYpzsLO/9OQ7gG/q5OzYgnD1Mv5K+5rpTUW8vFGtKwbXYJSu69kcJOiTk o6VU+p6iYrmujwKvpY4o6dU1f/++8agNoW/mOQgGqKw5doZuilEP+vI6Me5dxGyb4zjX C8h8kKzrGyCKx6zv2jEmXPCp0AeIIKvEOjI4m8uSfbWHhyn8H2DqdoghOp3O7rxnJSIH eF7frxfLh0qgcaGYBIaJTHWcSZ910gBWrlif6tWReWG5yiGvjWNwyEsjc0f027eBE20j d9EATfgeRlU3q725EHTPTGXR2dNORILdxkkqLam72lbCSj14Q88MfYcNfOPDIpLpBf/1 VBDQ== 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 w1-20020a17090a4f4100b001ecb8353c19si16686064pjl.69.2022.06.28.03.44.39; Tue, 28 Jun 2022 03:44: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; 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 S1344974AbiF1KjR (ORCPT + 99 others); Tue, 28 Jun 2022 06:39:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343572AbiF1KjQ (ORCPT ); Tue, 28 Jun 2022 06:39:16 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 741B72E9E2 for ; Tue, 28 Jun 2022 03:39:15 -0700 (PDT) Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=bjornoya.blackshift.org) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o68cc-00089w-0A; Tue, 28 Jun 2022 12:39:06 +0200 Received: from pengutronix.de (unknown [IPv6:2a01:4f8:1c1c:29e9:22:41ff:fe00:1400]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: mkl-all@blackshift.org) by smtp.blackshift.org (Postfix) with ESMTPSA id 3AD36A0E07; Tue, 28 Jun 2022 10:38:54 +0000 (UTC) Date: Tue, 28 Jun 2022 12:38:50 +0200 From: Marc Kleine-Budde To: Dario Binacchi 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 Subject: Re: [PATCH v4 05/12] can: slcan: use CAN network device driver API Message-ID: <20220628103850.4g2fyjybokraqz4b@pengutronix.de> References: <20220614122821.3646071-1-dario.binacchi@amarulasolutions.com> <20220614122821.3646071-6-dario.binacchi@amarulasolutions.com> <20220628092833.uo66jbnwhh5af6je@pengutronix.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="tbsrzes5xfujdruo" Content-Disposition: inline In-Reply-To: X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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 --tbsrzes5xfujdruo Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 28.06.2022 11:48:48, Dario Binacchi wrote: > Hi Marc, >=20 > On Tue, Jun 28, 2022 at 11:28 AM Marc Kleine-Budde w= rote: > > > > 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. >=20 > The rtnl_lock() uses a mutex while I used a spin_lock. >=20 > static DEFINE_MUTEX(rtnl_mutex); >=20 > void rtnl_lock(void) > { > mutex_lock(&rtnl_mutex); > } > EXPORT_SYMBOL(rtnl_lock); >=20 > 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? As Max pointed out the whole static dev array is not needed at all. Just keep the rtnl, until removing the array altogether. regards, Marc --=20 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 | --tbsrzes5xfujdruo Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEBsvAIBsPu6mG7thcrX5LkNig010FAmK62jcACgkQrX5LkNig 010jzwf/YtSV3kHaxcOCJQDr/oebHEMDUbH6lToSB5vR4Wo0ADsCZjTs5Z2HwNEv onCHfInDk50Ky1seqz0GrtIH9mPZIPLFyrQlTtFNfdkluQJy1/JnoZRBzkjMMDkD PS858Y/ntrQJDAAklT7c2YbNmvN9EkoNDSHMG6lVgB0IDY3+EHHHQKZf1sWh+4wf 3aQ8UHguqfqJWnGC43azlu1SzjVRmVQ322C0e8xyqXmpc/XZ9jHJAW/TWq/+2aD1 8wkZS1gkCyg0eCh4AK5tEHHxNWkhJrDDjB4NBY/G6Yg3RNxwgBOv/gVW2ndQIYJB nPNJcJ9+iIE2zrUEtHRZSHimkL/ZSQ== =bC7y -----END PGP SIGNATURE----- --tbsrzes5xfujdruo--