Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp445453rwb; Thu, 18 Aug 2022 06:40:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR4MDpGFuzqS6EOfO8hBOL3M1IVGO333uAgERqL1fZGlYS2cUcu7ThGtQoqx9FZzSfPFYUcq X-Received: by 2002:aa7:d3ce:0:b0:446:82f:eda4 with SMTP id o14-20020aa7d3ce000000b00446082feda4mr2325020edr.327.1660830009748; Thu, 18 Aug 2022 06:40:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660830009; cv=none; d=google.com; s=arc-20160816; b=tQqYYixR7O0nRCrFfkMFr6QJDZtSIRiwq0ZkbWPUP4Qj3oncZOoEM3lD5XZi6PZPmN vAEnAlh7cdaaWmZfRdNmFwYzR5WpF7GdkGJK5xOWoBHsDChYNNXUA2QjApoJEGiuW0kG h2rWUWiRuKUvqNoBtjW1/aMR9C+4LsXEzIr6ZPJ+lIuINyRi1pZnf88Vfhkn4MUxFldV u7H5E2Jg37aTSFKVjyIZAWdbnmpUXvBe8BGl/eGFmrwrld1B7vujnZLspdabfcTpt/aO bubs5X4HKd7fCXKwlRwLKQ3quVkve69v6U5GsJrdYRWxmTwgyKouFFV+WxLqRBTL1vPo XHkA== 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=LY+7kJ04hLsCkqsrPkbCRxVHMP+qrF55jT87hVWGac0=; b=oCWtwxzgTxeX5W2YpJ/YogOd04ctpmQxBvYMipv/HhxhLYRmr/dmNNzeIqERUtZFD5 ByUnMfYDb2DPu+iDBmQ/tc8PQ4dvSnDZHxYf5aaGEntsuAKQ2l8NgVZ79UU74Gt6ly5b xcGmThnEBC1yfCgQGvX9DTzMJN69IYdQ7cmzwZBrhGErexAjSveBQNm/LkGq7LYNdBf0 9YwoJxunzscandyLeTVOJ6w7iMhM1JpI5c5FA1rmSL1RzBGAjs42rRxj9AJj33iOoTHz pP0WxhXuolrHXgElHAZ1/FNLpxBwL5a8UPDv/axs5a3Lkx3QQCN+OmbTdZhvFW1P1qPq 4fWg== 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 j16-20020aa7c410000000b0043be0095153si1142860edq.439.2022.08.18.06.39.42; Thu, 18 Aug 2022 06:40:09 -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 S244926AbiHRNI2 (ORCPT + 99 others); Thu, 18 Aug 2022 09:08:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244911AbiHRNI1 (ORCPT ); Thu, 18 Aug 2022 09:08:27 -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 AE54137F91 for ; Thu, 18 Aug 2022 06:08:25 -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 1oOfG1-0000TO-Va; Thu, 18 Aug 2022 15:08:22 +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 AD3B1CD860; Thu, 18 Aug 2022 13:08:14 +0000 (UTC) Date: Thu, 18 Aug 2022 15:08:14 +0200 From: Marc Kleine-Budde To: Dario Binacchi Cc: linux-kernel@vger.kernel.org, Alexandre Torgue , Amarula patchwork , michael@amarulasolutions.com, Dario Binacchi , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [RFC PATCH 4/4] can: bxcan: add support for ST bxCAN controller Message-ID: <20220818130814.z7b4rvmld6wvk4fg@pengutronix.de> References: <20220817143529.257908-1-dario.binacchi@amarulasolutions.com> <20220817143529.257908-5-dario.binacchi@amarulasolutions.com> <20220818103031.m7bl6gbzcc76etig@pengutronix.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="dtkjkszqd6mas3zd" Content-Disposition: inline In-Reply-To: <20220818103031.m7bl6gbzcc76etig@pengutronix.de> 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,URIBL_BLOCKED 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 --dtkjkszqd6mas3zd Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 18.08.2022 12:30:31, Marc Kleine-Budde wrote: > One step at a time, let's look at the TX path: >=20 > On 17.08.2022 16:35:29, Dario Binacchi wrote: > > +static netdev_tx_t bxcan_start_xmit(struct sk_buff *skb, > > + struct net_device *ndev) > > +{ > > + struct bxcan_priv *priv =3D netdev_priv(ndev); > > + struct can_frame *cf =3D (struct can_frame *)skb->data; > > + struct bxcan_regs *regs =3D priv->regs; > > + struct bxcan_mb *mb_regs; >=20 > __iomem? >=20 > > + unsigned int mb_id; > > + u32 id, tsr; > > + int i, j; > > + > > + if (can_dropped_invalid_skb(ndev, skb)) > > + return NETDEV_TX_OK; > > + > > + tsr =3D readl(®s->tsr); > > + mb_id =3D ffs((tsr & BXCAN_TSR_TME) >> BXCAN_TSR_TME_SHIFT); >=20 > We want to send the CAN frames in the exact order they are pushed into > the driver, so don't pick the first free mailbox you find. How a are > priorities for the TX mailboxes handled? >=20 > Is the mailbox with the lowest number send first? Is there a priority > field in the mailbox? I just had a look into the data sheet and it says that the TX mailboxes are handled in transmit request order. This is good. [...] > The mcp251xfd has a proper hardware FIFO ring buffer for TX, the bxcan > probably doesn't. The get_tx_free() check is a bit different. Look at > c_can_get_tx_free() in: This means you can use the simpler get_tx_free from the mcp251xfd driver. >=20 > | https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/comm= it/?id=3D28e86e9ab522e65b08545e5008d0f1ac5b19dad1 >=20 > This patch is a good example for the relevant changes. This patch is non the less a good example for the TX path. 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 | --dtkjkszqd6mas3zd Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEBsvAIBsPu6mG7thcrX5LkNig010FAmL+OboACgkQrX5LkNig 0111dwgAsKHBnsZaWy6rH4/lkSd7m7BsivcwGcyfFO0SqgkUt/hKtV9luwypGM5y 0EpYLPJJDxJyZHtcv9Xc65ceMWYAu/KrodPF9gYvHdPusZLer42UZX7OSCZjRKg/ rg5QNEmMSFGsaXuOV13F2vkdUgCHqO+RMQzA1QkrCWXfGBfP8KEOBEyGkWRBWV3B EOiXp+XK1KLoHTD7cCCh0usmj+OqTc98mntbSq92UUB6UQph0PecyrNYU07PIvAW bZ9zoUdVC/0aAEGLHWY3pUXj7/nj8GxUiLCQiPH+Vvv+xYT2pe1kHpMWL7qp03WH NIfB5M8Vu2g7sAF39XW6q0VdHXTu0g== =JlUx -----END PGP SIGNATURE----- --dtkjkszqd6mas3zd--