Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp304451pxt; Fri, 6 Aug 2021 02:26:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/Y0JszX5cWUVDLLxoa3RdxAfvDhYCyROece+ZBCG6nsu9W0E0oa1YnEj2bEws7d2kOeEz X-Received: by 2002:a02:1942:: with SMTP id b63mr8857411jab.111.1628241996774; Fri, 06 Aug 2021 02:26:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628241996; cv=none; d=google.com; s=arc-20160816; b=a8H3eH0yVFuxweIO2wlDsGA8wFRnctvJrh96cdPC0OkMKI0dehSSwGFip0K/ZM8+i7 C+3FzBDnOJX3D8rn3vBJhhq3oJuij1IPCCYtX6AyIIgOfCqIajbwQYTC0BaYJ3hiuTup uvCEMTjes2/K2EimHKbtlLvT6b9INHClEChO5C9CG2+RsIwcNmjctTGgu52Wl6WmUIpq xBB7PKcGcUrib/3MFgFcp7LdUhaIty/JI62grOWScm0Vsm6ccMQCifDetFjNfZF2MRQB fCUwtiqVjp3nHGjc/leMXWAYDgKpfB3m7Uw7hPKDr9dKJ/2xBrERAEizP9Hh6z1eQlEm K4BA== 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=FvYqv6A6uhtKcwpmK0w7TKyTVu9hXjiai6GlfX/cxT0=; b=Bra1QOZSXQnAkl4kuoBzF23HF1fgPIJ7T4f8q9IdvIBUDQKRoNtovBwUPk+ZhYRHJD cj0G8AsBV8wLyMvAOMi9XTWVvxRK4LvaGE/YqncJEityoxRdDd360cO2QqZUD+71BgVm Fmy34UsdAZZojDclXK4Tgp3wRqLtfDjm2azthXZl2i4BgjOsDq+BZKvsh5L1g30ryA7z poIu8s4H75/uEXlxxUaoZ+keyOy8yzBgWd5ndX/3wonlK97FKa3UJRwPMYtfkMno0DIo UrukqRVzLe6HLk5Nv3AAAyXJrmJTkbD7fcesbtlpj3vbfwzpfW+B/OE6yeNU1WB2j6MA dHXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d2si379448ioi.55.2021.08.06.02.26.24; Fri, 06 Aug 2021 02:26:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244430AbhHFJZv (ORCPT + 99 others); Fri, 6 Aug 2021 05:25:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231489AbhHFJZv (ORCPT ); Fri, 6 Aug 2021 05:25:51 -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 9E156C061798 for ; Fri, 6 Aug 2021 02:25:35 -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 1mBw6b-0000hA-5H; Fri, 06 Aug 2021 11:25:29 +0200 Received: from pengutronix.de (unknown [IPv6:2a02:810a:8940:aa0:66f0:974b:98ab:a2fd]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) 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 58E50661D38; Fri, 6 Aug 2021 09:25:25 +0000 (UTC) Date: Fri, 6 Aug 2021 11:25:23 +0200 From: Marc Kleine-Budde To: Dario Binacchi Cc: linux-kernel@vger.kernel.org, Gianluca Falavigna , Andrew Lunn , "David S. Miller" , Jakub Kicinski , Oliver Hartkopp , Vincent Mailhol , Wolfgang Grandegger , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [RESEND PATCH 4/4] can: c_can: cache frames to operate as a true FIFO Message-ID: <20210806092523.hij5ejjq6wecbgfr@pengutronix.de> References: <20210725161150.11801-1-dariobin@libero.it> <20210725161150.11801-5-dariobin@libero.it> <20210804094515.ariv7d24t2i4hic5@pengutronix.de> <1485600069.218377.1628194566441@mail1.libero.it> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="7iqxv4fk64mddgi7" Content-Disposition: inline In-Reply-To: <1485600069.218377.1628194566441@mail1.libero.it> 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --7iqxv4fk64mddgi7 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 05.08.2021 22:16:06, Dario Binacchi wrote: > > > --- a/drivers/net/can/c_can/c_can.h > > > +++ b/drivers/net/can/c_can/c_can.h > > > @@ -200,6 +200,7 @@ struct c_can_priv { > > > atomic_t sie_pending; > > > unsigned long tx_dir; > > > int last_status; > > > + spinlock_t tx_lock; > >=20 > > What does the spin lock protect? [...] > > > @@ -483,7 +469,11 @@ static netdev_tx_t c_can_start_xmit(struct sk_bu= ff *skb, > > > if (c_can_get_tx_free(tx_ring) =3D=3D 0) > > > netif_stop_queue(dev); > > > =20 > > > - obj =3D idx + priv->msg_obj_tx_first; > > > + spin_lock_bh(&priv->tx_lock); > >=20 > > What does the spin_lock protect? The ndo_start_xmit function is properly > > serialized by the networking core. > >=20 >=20 > The spin_lock protects the access to the IF_TX interface. How? You only use the spin_lock in c_can_start_xmit(), but not anywhere else. > Enabling the transmission of cached messages occur inside interrupt The call chain is c_can_poll() -> c_can_do_tx(), and c_can_poll() is called from NAPI, which is not the IRQ handler. > and the use of the IF_RX interface, which would avoid the use of the > spinlock, has not been validated by the tests. What do you mean be has not been validated? The driver already uses IF_RX to avoid concurrent access in c_can_do_tx() for c_can_inval_tx_object() [1], why not use IF_RX for c_can_object_put(), too? [1] https://lore.kernel.org/r/20210302215435.18286-4-dariobin@libero.it 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 | --7iqxv4fk64mddgi7 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEK3kIWJt9yTYMP3ehqclaivrt76kFAmENAAEACgkQqclaivrt 76lMMwgAjXgHSoDKSNnaDwB8xLfHIA0i0vgMnwo+f82AnyFrFRJil6i4UyYDEdRP FUZ6Gvi8/rG838Wf+lklNcdz66bhPI4WF+fwC76xekDUWqG4KJPJZyg17RiZ7ESU G+bk7aOZB34Je45xLxcuTFncnM48Lb8M5PwXrkO36R2GMo2qrfKN3cAKm8B6Fz+y 7p/5/j/d0D0GB8HbYUY64bccuF/iCr4uDaXD3MSbwTrF/QdckMy6yPmjpFfaMMLz 5ksHn/d7hO30GvAQJmr4nmYiksFBTrUwio1wnYbdiM3A2E+6Syqh8vbWDH3x5m8p EQJypD3+YjvwpRVb9hR5DRFtLrIIhw== =lEmb -----END PGP SIGNATURE----- --7iqxv4fk64mddgi7--