Received: by 10.223.176.5 with SMTP id f5csp1550068wra; Wed, 7 Feb 2018 22:49:39 -0800 (PST) X-Google-Smtp-Source: AH8x226aZD7eXzq7qZEJ6IerP7chISNXEyF8903p+mSlVcEZ3Hqr/SBZ7DRBODdWZwt/MRXiXwl2 X-Received: by 2002:a17:902:a515:: with SMTP id s21-v6mr8589921plq.393.1518072578959; Wed, 07 Feb 2018 22:49:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518072578; cv=none; d=google.com; s=arc-20160816; b=zyif8LNOn6ObKbgMCmXOsEizFFmMme+D8i+T+OFlAMVHJqdnVFz/rYFhW8qtczxo3N 6GA4PGenv4aDsYf2+chNEiCBsG3/30L2qNWYPP49YkBkQRhERmz6XgZ9QWN6y1dcf3Sk FW8L1OauCZmuCPvHp61UQglecHPIBN+WS1XPlItf7784Z85wZfvDdE9Ad1HA6Jf01itx 9RhbeuAcx2XAcQz+sOLgTU9CyHqs5xYnUmyQeAYfQasgqGcMCJbjuxosGIyyzR3Z+/9D xbPhc9zn+Gs4A5cg/b38NCXPuRr/U4w2cuyUZjZOm+wpN79AT0WC0Gxywwgxf1VGvzdE 5QlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=bkAfcDuPVSzulrDCNtRntjz8LmAt2RZ44SVJF3Pz9kg=; b=q2OJeAaJN/bR3LSva2NBwUgFfiPyKFD0vskbs4ZMrTauswIn0s++LxcHOYiy47YD76 xfXq3qAEcpk5qWItsQu9UnZomRar6k8gfHL+ivEzllZRB4A0EVLNuBbXpz8IT4zWFQhm vG2i80yBya/TLJOuSew9Nj4ibQxNhCIc3y4quqtpfZ5jwMnxESPiCUQaESzNyL9kj1vH RQOoxlNeADUu8amSRwFvnkQ+IYM65SSSD/KJRxZvSNEOYxCYgV53oCF2ayJGEOFRkomy lbe1VgMNFnrdywTPswem7zbhMeLNVCY1kbGAl5wFnZPcYmQUNazcTtrYKUHuWqLfP74E 8FbQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r2si818724pfg.36.2018.02.07.22.49.25; Wed, 07 Feb 2018 22:49:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752205AbeBHGsV (ORCPT + 99 others); Thu, 8 Feb 2018 01:48:21 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:47061 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750847AbeBHGsS (ORCPT ); Thu, 8 Feb 2018 01:48:18 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 3zcTKs2X0pz1qvPT; Thu, 8 Feb 2018 07:48:17 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 3zcTKs2HC0z1t8pj; Thu, 8 Feb 2018 07:48:17 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id id6P9ieH7zGP; Thu, 8 Feb 2018 07:48:15 +0100 (CET) X-Auth-Info: /wfQhFu6rPAvTw4MhPX3e5LJpupq7sUBKZxP5n/zb+o= Received: from mail-internal.denx.de (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Thu, 8 Feb 2018 07:48:15 +0100 (CET) Received: from pollux.denx.de (pollux [192.168.1.1]) by mail-internal.denx.de (Postfix) with ESMTP id 66409180930; Thu, 8 Feb 2018 07:48:00 +0100 (CET) Received: by pollux.denx.de (Postfix, from userid 515) id 4417A16A2; Thu, 8 Feb 2018 07:48:00 +0100 (CET) From: Heiko Schocher To: linux-can@vger.kernel.org Cc: Heiko Schocher , Markus Marb , netdev@vger.kernel.org, Marc Kleine-Budde , linux-kernel@vger.kernel.org, Marek Vasut , Wolfgang Grandegger Subject: [PATCH v2 2/2] net, can, ifi: loopback Tx message in IFI block Date: Thu, 8 Feb 2018 07:47:48 +0100 Message-Id: <20180208064748.17985-2-hs@denx.de> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180208064748.17985-1-hs@denx.de> References: <20180208064748.17985-1-hs@denx.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Current ifi driver reads first Rx messages, than loopback the Tx message, if the IFI_CANFD_INTERRUPT_TXFIFO_REMOVE bit is set. This can lead into the case, that Rx messages overhelm Tx messages! Fixed this in the following way: Set in the IFI_CANFD_TXFIFO_DLC register the FN value to 1, so the IFI block loopsback itself the Tx message when sended correctly on the canfd bus. Only the IFI block can insert the Tx message in the correct place. The linux driver now needs only to free the skb, when the Tx message was sended correctly. Signed-off-by: Heiko Schocher Reviewed-by: Marek Vasut --- Changes in v2: - add Reviewed-by from Marek, fixed comment into one liner drivers/net/can/ifi_canfd/ifi_canfd.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/ifi_canfd/ifi_canfd.c b/drivers/net/can/ifi_canfd/ifi_canfd.c index 05feb8177936..ee74ee8f9b38 100644 --- a/drivers/net/can/ifi_canfd/ifi_canfd.c +++ b/drivers/net/can/ifi_canfd/ifi_canfd.c @@ -211,6 +211,7 @@ struct ifi_canfd_priv { struct napi_struct napi; struct net_device *ndev; void __iomem *base; + unsigned int tx_len; }; static void ifi_canfd_irq_enable(struct net_device *ndev, bool enable) @@ -617,8 +618,10 @@ static irqreturn_t ifi_canfd_isr(int irq, void *dev_id) /* TX IRQ */ if (isr & IFI_CANFD_INTERRUPT_TXFIFO_REMOVE) { - stats->tx_bytes += can_get_echo_skb(ndev, 0); + can_free_echo_skb(ndev, 0); + stats->tx_bytes += priv->tx_len; stats->tx_packets++; + priv->tx_len = 0; can_led_event(ndev, CAN_LED_EVENT_TX); } @@ -889,6 +892,7 @@ static netdev_tx_t ifi_canfd_start_xmit(struct sk_buff *skb, } txdlc = can_len2dlc(cf->len); + priv->tx_len = txdlc; if ((priv->can.ctrlmode & CAN_CTRLMODE_FD) && can_is_canfd_skb(skb)) { txdlc |= IFI_CANFD_TXFIFO_DLC_EDL; if (cf->flags & CANFD_BRS) @@ -898,6 +902,9 @@ static netdev_tx_t ifi_canfd_start_xmit(struct sk_buff *skb, if (cf->can_id & CAN_RTR_FLAG) txdlc |= IFI_CANFD_TXFIFO_DLC_RTR; + /* set FNR to 1, so we get our Tx Message looped back into RxFIFO */ + txdlc += (1 << IFI_CANFD_TXFIFO_DLC_FNR_OFFSET); + /* message ram configuration */ writel(txid, priv->base + IFI_CANFD_TXFIFO_ID); writel(txdlc, priv->base + IFI_CANFD_TXFIFO_DLC); -- 2.14.3