From patchwork Sat Mar 5 02:24:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12770229 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 546CFC433F5 for ; Sat, 5 Mar 2022 02:26:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UHmAIwHd1X1aB8Ra9nuyqh0HLhC+kiUBTM7cNssdu1M=; b=23Xmx2Us+VqipI xbSKLV+6OanV2zOISsD77QFqSFdmxGYJL/2sGt/+HPKfv0FTqOsTVGdMTRBdIeJmrX0XKnYcfhUuW N+iF8Y7XZHb7zSrqIuxwVEQwvFF9LhIastn1qmIVhllaaAhyr1NGWc3DIL8JZ16COcX/qWAgKUXNG PGwAQnN+XbVieiHC0iy7vHcSR3hXIXQs8qnmA347d9IZM9Bez75mdsOubjoVG/VMFQyNHkCTHETkt B9elcJhFuUUQMyyLpUD2NWhUGU6JzUNnlhMCzYTElU7izK1YKF95F7C6njU8RDFmLeYfV7ZsuskbY A23el1QOpQ4Hu0rHHgqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQK6s-00CaZ8-SM; Sat, 05 Mar 2022 02:25:31 +0000 Received: from mx0d-0054df01.pphosted.com ([67.231.150.19]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQK6c-00CaTm-C8 for linux-arm-kernel@lists.infradead.org; Sat, 05 Mar 2022 02:25:16 +0000 Received: from pps.filterd (m0209000.ppops.net [127.0.0.1]) by mx0c-0054df01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 22524FEj004428; Fri, 4 Mar 2022 21:24:58 -0500 Received: from can01-qb1-obe.outbound.protection.outlook.com (mail-qb1can01lp2054.outbound.protection.outlook.com [104.47.60.54]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3ek4hy8qgy-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Mar 2022 21:24:57 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L5cqxkflMskpb3E3E+YqTyE3R3pfOlrGUq2jtaXdBkHqmiDa5d0MCnYOEbGBQSkSGMXdXmdZdHsSiqzrH6HOznGXTifxp7byCKOqtK65cLLtVlsi1q6c237kA562bJ0aQkLTJRVpt4zSo9n5kt485ynzYe/yltpZIwTf185IFq0TWI7rSObj+9U5QotZgchjlNU4qMxeGzrIjXvV5px41Psb0FZ4421ZhwF5nk4gXqPfRWe6AIZIIHTcy28pJCVBq3lEs+B7zC8dj0QR3cl00VSZCl12hQN/vDDn8q6bku2qU2i7T5Q2DgMVLh/5fDBtQVD0nSsSjSWXAV+SvOkwZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6Uide2juYgLn/TgW4aWVCZGgm4nlf6vsd4r88ZedTZ0=; b=jTlPf9ZZENoUEY+8w6IDBsHUD5IOvLTp2C1z0JtQhqxnBALJoGTnlGBuQGhywAFOu6jYAcbEeckwkWsFaOuUtCHo3EdGHhwBqFjaPLvJG59+RfyOXF5AiRcToz/WwCTUWN5lxuI1OK/f1i9IghSe4i/oThBXd8XdoRcpE4lia9f9bpGRzYydbFMD/Pc1xQgAE11WE0w4DrjuiQ1G1vyE30vag+HoVnpPwjx8oP/WQBHr4/2d8R/Y736CoeqUKRhci+b9APMksziRl2INc2CCEyBSxUUXFYBOuApUe3NOWagnHrX44prgf6acVu+6hSeWkIoyeS7/5VobkNj4JwzPxg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=calian.com; dmarc=pass action=none header.from=calian.com; dkim=pass header.d=calian.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=calian.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6Uide2juYgLn/TgW4aWVCZGgm4nlf6vsd4r88ZedTZ0=; b=gbS4g4nQajdsqhOgZaoV6h/0qV/G7zigK1WtZjMI58yrJGtHxFXJdw2/8HCIxNERjnviGEh7MQqGi4MIsaghGS6herjTHvXEwKmxZWkHHxCCcvQDJBT6m5JZY4ZlM9NPYqUMxOQx7z0WGnE/HN6JQwNnVp4m1RKSa/BrYV4VitU= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (10.167.1.243) by YTBPR01MB3184.CANPRD01.PROD.OUTLOOK.COM (10.255.47.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Sat, 5 Mar 2022 02:24:56 +0000 Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::e8a8:1158:905f:8230]) by YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::e8a8:1158:905f:8230%7]) with mapi id 15.20.5038.017; Sat, 5 Mar 2022 02:24:56 +0000 From: Robert Hancock To: netdev@vger.kernel.org Cc: radhey.shyam.pandey@xilinx.com, davem@davemloft.net, kuba@kernel.org, michal.simek@xilinx.com, linux@armlinux.org.uk, daniel@iogearbox.net, linux-arm-kernel@lists.infradead.org, Robert Hancock Subject: [PATCH net-next v3 1/7] net: axienet: fix RX ring refill allocation failure handling Date: Fri, 4 Mar 2022 20:24:37 -0600 Message-Id: <20220305022443.2708763-2-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220305022443.2708763-1-robert.hancock@calian.com> References: <20220305022443.2708763-1-robert.hancock@calian.com> X-ClientProxiedBy: MW4PR03CA0304.namprd03.prod.outlook.com (2603:10b6:303:dd::9) To YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5fb5465e-8abc-470a-1828-08d9fe4f56c8 X-MS-TrafficTypeDiagnostic: YTBPR01MB3184:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dEM+8zwHSC56DhkZn8zjl8hLQabZ+5SCryW7vg1ubxoop3M1pPIunEWKcU+BS66ghiLR8UNyb+9DKTRHy9zuYu3YGtCifLwNV+B9c0WWC1bVt4S9rRhCOUPqfmmcP1YdK0PKLw4vHcRnwPDHEkxJ9RPn6xPO0tdOMKBGR7v0IiDHYxM39YxQ3MNCnmWrjRWKwGq4DOYaDa35oqGj/C7IbnSjqQ7rDEOWvxZVu87KA2jZ5h4K5ywsP35GppNk6GdT4wl0wsQA1oXp6vzBWSMdgI/SxkZaoNazTy03JpHl/OR5dUU8XnVVf2nRS/On5LU97FX7SFHp6e1/sv8Pnfm8txQ9Itfd6wr2INjUbYM6utYsVRW0RNtgD8kazccb5a6MQhPe+YNgs2/ricT4L8n0Na/RJkzXVDrFBYg3N4uTNJpGBvr+OBQk/PQewi1eJ1EhAobQfEGd6BlSiI0DxHr5QOQ3aHsCa7zHDTNy8bzn3gkABZ6WRafMumUfUu/p4KNRtKq/LrHwL/Svon7ZuAaLe1TUIqysWUNtUFUF51DtF/pwHpErONNUtDmsJPYj/k4cvmq3wU8uVgOeBB91/KP0oovlbzfdvHpvcPSiyLxoJ2JDlgCs3qCOIXOe7qxoAOg2iGq+T/7QP8vsvRrZVFWr36bl2y0/xpALJNh+C6s961hTfSScpIwxL5DdE0jt8jZLuzezW1QnNguqJvuPmeOavA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(36756003)(2906002)(107886003)(5660300002)(26005)(186003)(83380400001)(6916009)(4326008)(2616005)(1076003)(8936002)(44832011)(6486002)(38350700002)(38100700002)(508600001)(86362001)(316002)(6666004)(52116002)(8676002)(66556008)(66476007)(66946007)(6506007)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cCrySQlOHdfzw99XBk3artpnDOZAE/WVLONA+RXI8a+n4JuES+mdt1nVYy83Si1TzLgWX0DRpv8ZMtMXrrOKK5leOUzMvhmxKHMNbIHS4UWIuovTYfJgkMSx/p2jHxo57hZLndFSHegtraR844GO51WAHlE8gEjGD0sZ2bDMgo2hiZpWG8NJjc6rhrqkjTdajXtnIqAxmWDMoBENlm6fH6kYwghcebR12NwPqCJ1rDn0Pjt3tAwd6iaMGXd7zxV4SaU/CMm6wovto7ws6a6UpcInnjiW02lvuJA/5a4+BE2cQUM3kyvlnnqCP9ilXous/gI4ehYDAh50u6ILQxVmGGpX6qvYRYFqFTPHnmpzeH5Hqx+NPcG6iogQJDVe4XGiWr3TpFnLDbZPYb3jnXssY6Rt1MkI0aaUDpAe+qkvUcJy3OKBLZOmyHbVCGZlDqdZ7FQEKHtemmArKBcMpThuWv5FMjPb4p+6fRSaiT0bhnQKZYyG2/cbDSj1Ub4H6hw3PXvxl0MoMYiNsAuZfyp9zX2k5YaPva5vICkLWjeJKU7cjxvz6Bd2nYlZtTtDwDbg+6i8jk/6MAZrVTugYCWYMUB0CHL6QwQPGMuMTenK8jxsNlKo4M+LlL+yzLyVzNzi+XEwPRq/rZGiyv0mi19Pv95UXHhdKuxYxCmi/Gos/zGwk9rim1QjxhK/kCAwwHdViOpunmbUgQWuqufCWy6ehl76ZgR9FagY6+VehB4By/9srfjl8N5dM7xxw4cryIXg9i4GU1/iN0Re7BLk+DPmM4MSHs+rTFwX/JCQB+qQCYd1xwZj4sDww0EWHK0ncHxSiOMdHXM3jPanxkfjLagLKRnxLllhOf77KCL2UdDY7GSR9Z/Ky3GwuOAEANejBIySM4I+7jrcku+CBARR6+B7sHtrovaBZbwhm1lneAvDYRnwqMTmDFT8iTtuX9DOO2mFDSVWv9lFLrtSI4Xkjfjzeyd8Q+tP/GU4Sda3rGj1IdhrxeBb0gcYVcRu3ZCPpNV3WRlEhOeRd4tv/oIH9xXMC0XKALe2dqDawN+FoArqazUdQAiBJLJODPNbuMRVzQRZTu3lKZKG/4AbZiHTAf4cm+D1QD8wYAMFJH2PbtWvVPhznAUFGHguFwYQunDaHsDuWSb3NfbSv/Wx1O6CiyvCTRLYu+tj2nLpWcMwchWR6Yv5Jk+LwUGQDThUQjztF2AWem7WhIQ6rwCakS1g0IRlh6eEleMlhMsugnTJum72WxyL37iber+XbvRv2z7RqH3bVag52ie27/fGjtAVcF6WF6PiJzCvDCAtlNzhcrb9l3IgV8StqYucIbzrTdEPAwxVxE9Ca944ahaQZHIVglb7kIpbCyF5e5uVs79+HS5TIQ+Ph4Y3Il/NBgkky1dvmQqU3B7DRkB9key8lAsyx10PofDHiL0F+Ua07ikdUK4RNtP88U14KnEM+a26fVdHeci/pp6A7U2zniR6Vzj/Y3BvvjHYA+cKjT38c69iEyQxtBOD8V9BAXjSXnG+kGB2RBmEg9yZuf++CfNnrEjXoG6M9ZwUGhW1FcLv/rFDmOKbEaM/9nK/qrxno9Lpcsxw/HMR572Fllr8UcHMHUOlettJhlnxFi6WzsYTQTmQ6Sgvb3PmmVIy8eBIY2v1x2XPvbJnU7XGFo5dxMip5baAGDb76WpJXpd5LctGyUmoQRbtMLE= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5fb5465e-8abc-470a-1828-08d9fe4f56c8 X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2022 02:24:56.2867 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 23b57807-562f-49ad-92c4-3bb0f07a1fdf X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vYnUSNPo3VyO5nh/ipR3Ce1bnFZbrlkSFsNfU0xZXffx/kFetTP9uXDjKUnopW3TJRtMMBYVmakHSrdHQY8yZHtFm6mLv4KG6kQdQy9OOFg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YTBPR01MB3184 X-Proofpoint-ORIG-GUID: T7u1PyLK3pKL9M24NiPW5RZE4eqU_Ydp X-Proofpoint-GUID: T7u1PyLK3pKL9M24NiPW5RZE4eqU_Ydp X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-04_09,2022-03-04_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 mlxscore=0 malwarescore=0 impostorscore=0 clxscore=1015 priorityscore=1501 adultscore=0 mlxlogscore=481 phishscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203050007 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220304_182514_559095_CBDC3E86 X-CRM114-Status: GOOD ( 20.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If a memory allocation error occurred during an attempt to refill a slot in the RX ring after the packet was received, the hardware tail pointer would still have been updated to point to or past the slot which remained marked as previously completed. This would likely result in the DMA engine raising an error when it eventually tried to use that slot again. If a slot cannot be refilled, then just stop processing and do not move the tail pointer past it. On the next attempt, we should skip receiving the packet from the empty slot and just try to refill it again. This failure mode has not actually been observed, but was found as part of other driver updates. Fixes: 8a3b7a252dca ("drivers/net/ethernet/xilinx: added Xilinx AXI Ethernet driver") Signed-off-by: Robert Hancock --- .../net/ethernet/xilinx/xilinx_axienet_main.c | 72 +++++++++++-------- 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 336929511e42..3457a7f13747 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -857,46 +857,53 @@ static void axienet_recv(struct net_device *ndev) while ((cur_p->status & XAXIDMA_BD_STS_COMPLETE_MASK)) { dma_addr_t phys; - tail_p = lp->rx_bd_p + sizeof(*lp->rx_bd_v) * lp->rx_bd_ci; - /* Ensure we see complete descriptor update */ dma_rmb(); - phys = desc_get_phys_addr(lp, cur_p); - dma_unmap_single(ndev->dev.parent, phys, lp->max_frm_size, - DMA_FROM_DEVICE); skb = cur_p->skb; cur_p->skb = NULL; - length = cur_p->app4 & 0x0000FFFF; - - skb_put(skb, length); - skb->protocol = eth_type_trans(skb, ndev); - /*skb_checksum_none_assert(skb);*/ - skb->ip_summed = CHECKSUM_NONE; - - /* if we're doing Rx csum offload, set it up */ - if (lp->features & XAE_FEATURE_FULL_RX_CSUM) { - csumstatus = (cur_p->app2 & - XAE_FULL_CSUM_STATUS_MASK) >> 3; - if ((csumstatus == XAE_IP_TCP_CSUM_VALIDATED) || - (csumstatus == XAE_IP_UDP_CSUM_VALIDATED)) { - skb->ip_summed = CHECKSUM_UNNECESSARY; + + /* skb could be NULL if a previous pass already received the + * packet for this slot in the ring, but failed to refill it + * with a newly allocated buffer. In this case, don't try to + * receive it again. + */ + if (likely(skb)) { + length = cur_p->app4 & 0x0000FFFF; + + phys = desc_get_phys_addr(lp, cur_p); + dma_unmap_single(ndev->dev.parent, phys, lp->max_frm_size, + DMA_FROM_DEVICE); + + skb_put(skb, length); + skb->protocol = eth_type_trans(skb, ndev); + /*skb_checksum_none_assert(skb);*/ + skb->ip_summed = CHECKSUM_NONE; + + /* if we're doing Rx csum offload, set it up */ + if (lp->features & XAE_FEATURE_FULL_RX_CSUM) { + csumstatus = (cur_p->app2 & + XAE_FULL_CSUM_STATUS_MASK) >> 3; + if (csumstatus == XAE_IP_TCP_CSUM_VALIDATED || + csumstatus == XAE_IP_UDP_CSUM_VALIDATED) { + skb->ip_summed = CHECKSUM_UNNECESSARY; + } + } else if ((lp->features & XAE_FEATURE_PARTIAL_RX_CSUM) != 0 && + skb->protocol == htons(ETH_P_IP) && + skb->len > 64) { + skb->csum = be32_to_cpu(cur_p->app3 & 0xFFFF); + skb->ip_summed = CHECKSUM_COMPLETE; } - } else if ((lp->features & XAE_FEATURE_PARTIAL_RX_CSUM) != 0 && - skb->protocol == htons(ETH_P_IP) && - skb->len > 64) { - skb->csum = be32_to_cpu(cur_p->app3 & 0xFFFF); - skb->ip_summed = CHECKSUM_COMPLETE; - } - netif_rx(skb); + netif_rx(skb); - size += length; - packets++; + size += length; + packets++; + } new_skb = netdev_alloc_skb_ip_align(ndev, lp->max_frm_size); if (!new_skb) - return; + break; phys = dma_map_single(ndev->dev.parent, new_skb->data, lp->max_frm_size, @@ -905,7 +912,7 @@ static void axienet_recv(struct net_device *ndev) if (net_ratelimit()) netdev_err(ndev, "RX DMA mapping error\n"); dev_kfree_skb(new_skb); - return; + break; } desc_set_phys_addr(lp, phys, cur_p); @@ -913,6 +920,11 @@ static void axienet_recv(struct net_device *ndev) cur_p->status = 0; cur_p->skb = new_skb; + /* Only update tail_p to mark this slot as usable after it has + * been successfully refilled. + */ + tail_p = lp->rx_bd_p + sizeof(*lp->rx_bd_v) * lp->rx_bd_ci; + if (++lp->rx_bd_ci >= lp->rx_bd_num) lp->rx_bd_ci = 0; cur_p = &lp->rx_bd_v[lp->rx_bd_ci]; From patchwork Sat Mar 5 02:24:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12770230 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 774BCC433F5 for ; Sat, 5 Mar 2022 02:27:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=olPmklYG86WHO9u1WlWw6O4D5zz2rpIJUMNsl/A9Ds0=; b=UxTNA4m2sKb48X txjYMiOH9ntIU8r/mEcKVqwewg8gXYiC2301w5FqJaAX9XXhoxWIxnDrm3Oj5ATXPeve+k5ukVApO /z7QvDtixAnOAqUlgP+2fvDH601/Z0csL1Mds482WPIJeS14hKzBTEQ744DNrdxcXZKBlDshIbKr1 Zz1Uj6i38URa6tUTZpDAFmGcrJRfbUNIQdBbPS96OJj+Hk/EhGSgHp0UQsNN38+Yp85UzfKO5iPw8 fjefyGDTW39NaWZJ+C53edANXmyjTnI9AAeWLr1B4m/np9+exYWtEoj0jJ9CgzV+1AY9yyijDvADd isBz+qiZq4Z0N0JSeGdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQK74-00Cad7-Ng; Sat, 05 Mar 2022 02:25:43 +0000 Received: from mx0d-0054df01.pphosted.com ([67.231.150.19]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQK6c-00CaTx-OO for linux-arm-kernel@lists.infradead.org; Sat, 05 Mar 2022 02:25:17 +0000 Received: from pps.filterd (m0209000.ppops.net [127.0.0.1]) by mx0c-0054df01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 22524FEk004428; Fri, 4 Mar 2022 21:24:59 -0500 Received: from can01-qb1-obe.outbound.protection.outlook.com (mail-qb1can01lp2051.outbound.protection.outlook.com [104.47.60.51]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3ek4hy8qh1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Mar 2022 21:24:58 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wvyz+wLLsm2TJr2E+k8EizpBO6XAEVQwmChl/+sirHa5Fao8aWiCVXf10/ttzC0X08bft3c9L9Sp1fdZaF/oH32Da9ZF6GXk7VDaOkkPVmu33mLBDv33LxcXUa3FamuraFt4XAc/1wQ+2nJ1BNxSiwgLCRNvt0pjsd05NS0UonhHyMd6GxrYMEUpuEKtgxJ8LhQQWz6SCsFBidfi8HKMDt3RfFeuE46hsMkWlKE1dw8rUWn2IMkml0w19q83X1tGcvOAWkm/UcfHDSWTiVHWF0ehazUzCFP/PxWk2Wpeo8+NvjAzhnAEYnc9kWqRxnrKfVZYHykljHRS5k8qh0e/og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Hbsz6wDcjqlIRWTFKuKUW8d+CfW2Sx4F3QeW3d+dLzg=; b=MgYZ6p282LdWEOmndSQqLJ9fXeXDuvhqwpTbDpIT5YjSTqgvYP4a+6GPwrz7FNsEkwP9KonCDBwOUR7qnh4E9UBehfnFjKhZ8xOrgPwK2gXR6zPKl4Ld5wB2ed+FG6bkjpQxYRHZKTp/bwlsCCM5Y+J7gvFkAhkwTMbr5jL/ivzJgEqk0B7kcleLJKrmlmEC9v/JBexhz9RE44IJ83mvzONnkC30oH8f24kQhzKiQ5Dh6e1m65w7qgfa2cgMSOAHkUv/aRJl2hM9F72XsLqzpw81/s5avoQoKLLaNYnz5n8OyfZNINjHls9NnTBNdqUfeEVerj69kjr/Gu3NJN0AZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=calian.com; dmarc=pass action=none header.from=calian.com; dkim=pass header.d=calian.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=calian.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Hbsz6wDcjqlIRWTFKuKUW8d+CfW2Sx4F3QeW3d+dLzg=; b=p+qjTEdbUytiHYECNhSnZKgWqnM9aa28pV8fRA4613QJqF3rJy63rgPHuh8dB+Mt8JMEQXz1oTCPi+xkX/uz99eyGa7glutrq6/z0SkSnFgYdd05r91TNdG67Bu3kgEGHvsMcF+zI4I99Gpk9Xc7jJglzzp2aJwnFTmv6DLqEao= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (10.167.1.243) by YTBPR01MB3184.CANPRD01.PROD.OUTLOOK.COM (10.255.47.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Sat, 5 Mar 2022 02:24:57 +0000 Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::e8a8:1158:905f:8230]) by YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::e8a8:1158:905f:8230%7]) with mapi id 15.20.5038.017; Sat, 5 Mar 2022 02:24:57 +0000 From: Robert Hancock To: netdev@vger.kernel.org Cc: radhey.shyam.pandey@xilinx.com, davem@davemloft.net, kuba@kernel.org, michal.simek@xilinx.com, linux@armlinux.org.uk, daniel@iogearbox.net, linux-arm-kernel@lists.infradead.org, Robert Hancock Subject: [PATCH net-next v3 2/7] net: axienet: Clean up device used for DMA calls Date: Fri, 4 Mar 2022 20:24:38 -0600 Message-Id: <20220305022443.2708763-3-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220305022443.2708763-1-robert.hancock@calian.com> References: <20220305022443.2708763-1-robert.hancock@calian.com> X-ClientProxiedBy: MW4PR03CA0304.namprd03.prod.outlook.com (2603:10b6:303:dd::9) To YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2a1b04b3-ee8b-4700-8e01-08d9fe4f578b X-MS-TrafficTypeDiagnostic: YTBPR01MB3184:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mqU+vWlDp4Dul4/Q3rkmgmkZ/M867Au2o0Eev6fserAoSP5lOSlVbkwGHzUDhKJCiSUO6FGv8RK21DUBb3AcvBecLT4FLeBn7dQuU3l2WwAx0WgoiHOJu2hsktiqag522HoX8KWRZLRZ/osj8zlPK9wm57OqxqkvdmnmLM/fwCO7dqMK2gFRLeTgLao1+SWxBltupXfe1kaAriV5fvRJCYFXpGVHGvAs9iF5J8D2x0mtvGqp7TwE+TsTGQPWK7mlTVnJwv6+MbnrsDGkZRXPjE+A+zrMV41q+W5O2BDhI5fqShuBQSWWvf/5oCnEmoRhsKsKwVSbI5EtS850SxzB+s2GAobqyH7S0okn/rbXpl1u/wdoE8753UPVwXD/BDCV0yOVy9GabeWzUGsQXCgeopPPvt32xoN7Jqk1FXAFhsagGyAXiXiKvPVse/gArOvuqujrLlBrEabaTaRcw0v4qO4wXd81crAixfzkXwINa1Ce7LrqXvud66ruQR4DJuMVrheBS+4yPb3Z5bCE7awFlOB+Z7tbAyVa9euP9hUMX6mn8DZHV2E7jL6KVrMPVIj6S7AGbQ1LXgIj8JOkH/8jpZDpS8Eib24cWc6DYXVkRE4oYVgpm3fg+icC5+AZMS+X2W7BaE1+9ZInnXSXLogjZJHuFkWzb7J59l4wvOaim8vi6ju378vs3Z3jF2IQYoLDgkdAICUNTc2l/jBP90e+yQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(36756003)(2906002)(107886003)(5660300002)(26005)(186003)(83380400001)(6916009)(4326008)(2616005)(1076003)(8936002)(44832011)(6486002)(38350700002)(38100700002)(508600001)(86362001)(316002)(6666004)(52116002)(8676002)(66556008)(66476007)(66946007)(6506007)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ReD9R1dN6oOEVtY0ZqQfTKxD0xjz8CLNZpjxH4lLnl8+pVK3ZJmHcd21AJf+5azHxE9Rvv5U/xTzmATt3x0rR6SFeS7anGq0Hgl9DU28s8MQCy7MN4rcf5819WpoKD6R79zp56SeOGrMaWnazyYOPIqwRdCnW5+ZPyQ6qvUxhWO666iI/VrPzoo7zKEO4UsAZ4l9UjKPkesXZmyGD7KVerRYMtEz42JFSuyxj78/RE3meUZLzakVuNOKhu0k0TF7g7Tn4rSJOepfelF8iDvFzYfM2Ed00GA5rzw6yrHT03KwRa+Fk8uOZE7w6hsTqbcJ7agJx52vrQc9qwlCP+m/yX6HPzXpT/rcsfmHV1mTfiOUwMwt/m0vNdKPdzWijfRunCioMoXN9VTkLdcvbR1JyuoC9+b0qyl8F8+5CmiRyvnxeL+o4LCZjU9llzfFcj/0IiFYZlts4HupLfYGQvAPls5yziNIakQR6mbOe6HbNUs7jHihXXxKPksW0cPFDoX3UVShfr1pPV9VFFxWMcvDyaGGUYDI9WqGqLjY2sFh1pp0m6jRV3epicVMRqGxR9Tf2CoWLpzZhChiH76PL/P8og9UU9WUIrgvAKDjsbEu9EagpJrJqW8z+CUBa3Jk4uZSG8w1F8Ivf5KHzan0Ns3wMG4po4FjyITcAZXbGbJLy3bV0qCG0n87TIpEgvnHaCTS+OUdJSxKHsolqXpZ/R43s8Jhmw6pZJFAQOjD/Cbj/n5YcVXurrUBZQzyqR4tMLhjTkoG/V94T7Ai+6eqvJSGmbfo6LZXx/fQA4RTLBb1czBXC2DUY5blYAAxNLxuhygVmOldB9Phw/gBcHF5D76oOC5C8EFR+LDwYceH3vOEhKizPRSw6f8OZqRWKAApqHlPuZG7H92rnYJ6aT8jl6gh8Mr37NLDAqldhSr135NYHvQ0ST3qmibYAf9THLt3GMQSUkxM8Cix7hVvgNQrN9spfJO5yTZ3YmHvOxlW2uGI/Pj9KmSCYDIlGTk1q5bdPV3u8GGFiQTPb8jURCpHb4tqhF1L5hlb9cpie1GBhL3sSqGtxxqT7sO3AG7YVt797hIo8GbLP4jfhQGjCUh8euuMgf9+zQ9thR+g19UQ/3H+1I29gfdu1+SX84cSG9r0e53A81L54bqOd4z/HdeFWEJdqk4Bp5NFCma435C602wnt3NrBiuVUoImUn3II/5LlDRdQOs0qyYwLl+1DN3dfUs/OI/G+z9Bp0MFAul59+tX80/Or+q8TNq29pZZgLNoLLqbBvGkbOVWPfOL+1xQoD23s/tPkjuOdEEpSPWf3kjCtgJmO6wCacYFmtTfWoKP16K6qNWY6A8hBGCbmmW++6E3fcysT6HjC35tHiFolvILK4GCip6RWXM0vu6gH1ml0NJ1rG89RNGCFRIyOjYRA0GOMNg3/sKKC2rTEqsxPZiVzNPpQPmSrqFCMDz1nLpFwRSjvim9eTinQ8wmYF/hmQGMrtglDdQyGNN0cMxVtGnQoKr5QBonrRbH4gMlCW12o3DdjltHz7vwxrOJxWvoN8K/G4uIkU09+TSOcjyu0XtQO7eqC3M/UflkdjV7PH8yHWxzlCbIyFjesx1UahugGGOzXGK6NTHMXRgxqVGbwk6XGwgODhv/lY+/bQ/wLvKrnY6FxQF6siDfK5TfGEDotvSafqhx9eKzdTibAvMPBWutPFE= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2a1b04b3-ee8b-4700-8e01-08d9fe4f578b X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2022 02:24:57.5520 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 23b57807-562f-49ad-92c4-3bb0f07a1fdf X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Jg3ldLHva+1CemEJHtkVevroMrDQeojnylBwx7HBeGmMpHG20UdrgE6iQuJCIfj+yrYHJK+xuQWT+YkHblShT+ejC8R7TBXjn/9LLb+TA2k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YTBPR01MB3184 X-Proofpoint-ORIG-GUID: Piva6rHVLSuet7GdxFPhQFa9cC_8AP-j X-Proofpoint-GUID: Piva6rHVLSuet7GdxFPhQFa9cC_8AP-j X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-04_09,2022-03-04_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 mlxscore=0 malwarescore=0 impostorscore=0 clxscore=1015 priorityscore=1501 adultscore=0 mlxlogscore=774 phishscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203050007 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220304_182514_951882_AF205DDE X-CRM114-Status: GOOD ( 13.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Instead of using lp->ndev.parent to find the correct device to use for DMA API calls, just use the dev attribute in the device structure. Signed-off-by: Robert Hancock --- .../net/ethernet/xilinx/xilinx_axienet_main.c | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 3457a7f13747..5a1ffdf9d8f7 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -190,7 +190,7 @@ static void axienet_dma_bd_release(struct net_device *ndev) struct axienet_local *lp = netdev_priv(ndev); /* If we end up here, tx_bd_v must have been DMA allocated. */ - dma_free_coherent(ndev->dev.parent, + dma_free_coherent(lp->dev, sizeof(*lp->tx_bd_v) * lp->tx_bd_num, lp->tx_bd_v, lp->tx_bd_p); @@ -215,12 +215,12 @@ static void axienet_dma_bd_release(struct net_device *ndev) */ if (lp->rx_bd_v[i].cntrl) { phys = desc_get_phys_addr(lp, &lp->rx_bd_v[i]); - dma_unmap_single(ndev->dev.parent, phys, + dma_unmap_single(lp->dev, phys, lp->max_frm_size, DMA_FROM_DEVICE); } } - dma_free_coherent(ndev->dev.parent, + dma_free_coherent(lp->dev, sizeof(*lp->rx_bd_v) * lp->rx_bd_num, lp->rx_bd_v, lp->rx_bd_p); @@ -249,13 +249,13 @@ static int axienet_dma_bd_init(struct net_device *ndev) lp->rx_bd_ci = 0; /* Allocate the Tx and Rx buffer descriptors. */ - lp->tx_bd_v = dma_alloc_coherent(ndev->dev.parent, + lp->tx_bd_v = dma_alloc_coherent(lp->dev, sizeof(*lp->tx_bd_v) * lp->tx_bd_num, &lp->tx_bd_p, GFP_KERNEL); if (!lp->tx_bd_v) return -ENOMEM; - lp->rx_bd_v = dma_alloc_coherent(ndev->dev.parent, + lp->rx_bd_v = dma_alloc_coherent(lp->dev, sizeof(*lp->rx_bd_v) * lp->rx_bd_num, &lp->rx_bd_p, GFP_KERNEL); if (!lp->rx_bd_v) @@ -285,9 +285,9 @@ static int axienet_dma_bd_init(struct net_device *ndev) goto out; lp->rx_bd_v[i].skb = skb; - addr = dma_map_single(ndev->dev.parent, skb->data, + addr = dma_map_single(lp->dev, skb->data, lp->max_frm_size, DMA_FROM_DEVICE); - if (dma_mapping_error(ndev->dev.parent, addr)) { + if (dma_mapping_error(lp->dev, addr)) { netdev_err(ndev, "DMA mapping error\n"); goto out; } @@ -636,7 +636,7 @@ static int axienet_free_tx_chain(struct net_device *ndev, u32 first_bd, /* Ensure we see complete descriptor update */ dma_rmb(); phys = desc_get_phys_addr(lp, cur_p); - dma_unmap_single(ndev->dev.parent, phys, + dma_unmap_single(lp->dev, phys, (cur_p->cntrl & XAXIDMA_BD_CTRL_LENGTH_MASK), DMA_TO_DEVICE); @@ -774,9 +774,9 @@ axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev) cur_p->app0 |= 2; /* Tx Full Checksum Offload Enabled */ } - phys = dma_map_single(ndev->dev.parent, skb->data, + phys = dma_map_single(lp->dev, skb->data, skb_headlen(skb), DMA_TO_DEVICE); - if (unlikely(dma_mapping_error(ndev->dev.parent, phys))) { + if (unlikely(dma_mapping_error(lp->dev, phys))) { if (net_ratelimit()) netdev_err(ndev, "TX DMA mapping error\n"); ndev->stats.tx_dropped++; @@ -790,11 +790,11 @@ axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev) lp->tx_bd_tail = 0; cur_p = &lp->tx_bd_v[lp->tx_bd_tail]; frag = &skb_shinfo(skb)->frags[ii]; - phys = dma_map_single(ndev->dev.parent, + phys = dma_map_single(lp->dev, skb_frag_address(frag), skb_frag_size(frag), DMA_TO_DEVICE); - if (unlikely(dma_mapping_error(ndev->dev.parent, phys))) { + if (unlikely(dma_mapping_error(lp->dev, phys))) { if (net_ratelimit()) netdev_err(ndev, "TX DMA mapping error\n"); ndev->stats.tx_dropped++; @@ -872,7 +872,7 @@ static void axienet_recv(struct net_device *ndev) length = cur_p->app4 & 0x0000FFFF; phys = desc_get_phys_addr(lp, cur_p); - dma_unmap_single(ndev->dev.parent, phys, lp->max_frm_size, + dma_unmap_single(lp->dev, phys, lp->max_frm_size, DMA_FROM_DEVICE); skb_put(skb, length); @@ -905,10 +905,10 @@ static void axienet_recv(struct net_device *ndev) if (!new_skb) break; - phys = dma_map_single(ndev->dev.parent, new_skb->data, + phys = dma_map_single(lp->dev, new_skb->data, lp->max_frm_size, DMA_FROM_DEVICE); - if (unlikely(dma_mapping_error(ndev->dev.parent, phys))) { + if (unlikely(dma_mapping_error(lp->dev, phys))) { if (net_ratelimit()) netdev_err(ndev, "RX DMA mapping error\n"); dev_kfree_skb(new_skb); @@ -1731,7 +1731,7 @@ static void axienet_dma_err_handler(struct work_struct *work) if (cur_p->cntrl) { dma_addr_t addr = desc_get_phys_addr(lp, cur_p); - dma_unmap_single(ndev->dev.parent, addr, + dma_unmap_single(lp->dev, addr, (cur_p->cntrl & XAXIDMA_BD_CTRL_LENGTH_MASK), DMA_TO_DEVICE); From patchwork Sat Mar 5 02:24:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12770232 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C3F92C433EF for ; Sat, 5 Mar 2022 02:27:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7LtSyI7iex7eugrENw8g+PBrIoAynfPFwtvxuqHJvpU=; b=blJcuDmOiS3gx0 78BzXvfoI7sAntAbtiDwvJKw7Zn71b2dyPci6jAtraYs9fETBCHEpKaQjg5ieUJCog6t79b48/LTa 0aaWx0H1c+Lr1+3lJIYkEHjzGBCnEZbSI4nt8IE6FME9z1X+rxtL39n9mkE1plQJ1dwk5Oh7BEKY4 ISF8fHBmUI0qAPjviUu7EycG/lJdkdrRD+bfWub6Shz88m14rmTvrJdr8HrDUpeeqz++JDmnnSmFa Wd1YXOpHgvwwp/StutgDpXjpRGGrzCs9phhs0T+xrhzu6YI600eV91OzBSM7D3/H+2Ddj1zye4Q/e rokqnSaPvmgby40qJTlA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQK7Y-00CamL-5Q; Sat, 05 Mar 2022 02:26:13 +0000 Received: from mx0d-0054df01.pphosted.com ([67.231.150.19]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQK6e-00CaUd-Oy for linux-arm-kernel@lists.infradead.org; Sat, 05 Mar 2022 02:25:19 +0000 Received: from pps.filterd (m0209000.ppops.net [127.0.0.1]) by mx0c-0054df01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 22524FEl004428; Fri, 4 Mar 2022 21:25:00 -0500 Received: from can01-qb1-obe.outbound.protection.outlook.com (mail-qb1can01lp2055.outbound.protection.outlook.com [104.47.60.55]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3ek4hy8qh2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Mar 2022 21:25:00 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AC3PtFfDVZIISjsVQCCaPH8DKVr6gzPdJviXtMhCqT52kGHVUkgJml63m8zGjqmaiagMFrWofBGoNu+31yPBCUWyd7eDbiB97Vh1Ab0W3pyb7kUfwPle1k8bmVZUjuzbCkuluJSCfGpq97QvJ09QabXqxkqqhlEXvpYbGVqMJZyPDFF7pwHBbcLB7UqVzWEyzazwOIzpe5LpJE/L1mKXDsnWLrReLS+WmyWcNVPcUs8pJjOu1yJYpW7nwEHztXsYHcsxQ95NPvP3NTnqlRPIEq+JBFQsrKImNCKgkEQcupZ4Bsgv8b8Ezv/xvfDhrYp1jpEBUM8jH4lvzjWdQc0IzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KxpxjxCFXZlWDF24DkzLxeaNSzy9l3DlHkDk+1FV8Lk=; b=LnnMEPvJaYH9JTpetvZ8vOU+oUzs/n9ekL9ugq379A29XWYONWbKQ99jHU6tDdooK/M/96IPC4COWinyHPDdD+f5jjT1RkBelW2mdPOpPVYa4U2ITUI3eKjqhupku5ZbD8V9MH3+k+kDf3/lCY0K0t62VKyrkrBoekOOzx2m58Mq11H223zQqMfPR2iP0p6gy+peiKZZQHc2Wzqeria0naktiAexSrGfnU3epj6bYp8SA5tFNJYxYV7n2Kz+Ztxt6usmZPCJIoC8dQ7TJoa1YCjvSAEL+RAa/Yi5iRTDz49ZtRW9R8estRv2dHSllQzuj9rOBQM9fsfLlF5vzL8IwA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=calian.com; dmarc=pass action=none header.from=calian.com; dkim=pass header.d=calian.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=calian.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KxpxjxCFXZlWDF24DkzLxeaNSzy9l3DlHkDk+1FV8Lk=; b=UBWTN8WsEdi245hZyJAG+TTVAFuLS5etL4s/pe9sO77uP8uUDc+OgTi0z69NMMcCtnetThNz+Yt4P9Fc8SdaCfhniQPk2U8+oD+Iot/Ln8koXECaiJ++NTMFXZCqWgvdh7hmHGM/LyC7iE9Zd1+L8diFuqFgI5UIS5M0i2nEY+s= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (10.167.1.243) by YTBPR01MB3184.CANPRD01.PROD.OUTLOOK.COM (10.255.47.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Sat, 5 Mar 2022 02:24:58 +0000 Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::e8a8:1158:905f:8230]) by YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::e8a8:1158:905f:8230%7]) with mapi id 15.20.5038.017; Sat, 5 Mar 2022 02:24:58 +0000 From: Robert Hancock To: netdev@vger.kernel.org Cc: radhey.shyam.pandey@xilinx.com, davem@davemloft.net, kuba@kernel.org, michal.simek@xilinx.com, linux@armlinux.org.uk, daniel@iogearbox.net, linux-arm-kernel@lists.infradead.org, Robert Hancock Subject: [PATCH net-next v3 3/7] net: axienet: Clean up DMA start/stop and error handling Date: Fri, 4 Mar 2022 20:24:39 -0600 Message-Id: <20220305022443.2708763-4-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220305022443.2708763-1-robert.hancock@calian.com> References: <20220305022443.2708763-1-robert.hancock@calian.com> X-ClientProxiedBy: MW4PR03CA0304.namprd03.prod.outlook.com (2603:10b6:303:dd::9) To YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 979bc3e3-edaf-48f9-1afa-08d9fe4f584f X-MS-TrafficTypeDiagnostic: YTBPR01MB3184:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t3hWUor4ca4bbvF/vCj1W2/pu8Dn8wab23mHu//tN5oLXlAEkbHgLspXodZhrteUpPJCZGkiaeE5rRSxzYXpFyRCfwv/+qruqAubz3Ive6gIwENlNP2hhOXaRG/jq58KKfAMeo3u7dbE9O48EMi3/4cotzlUsxQtWrx8Mv6h5W6dkrLLAyopMdRDaElf1S+aA5G1RgryGbvyLVpcbzAdBPkPck2s/1Ye2e6zLNb03/KW/d0r9pfTdl2uVhnwwfsQRQ5yehDyHJ+mCRafpvlxOZmVO5uoTeXq3Di5yJ1FAktkr9wdAUafCCwxVdDZ7GkCq7gDNc2ewGf459eEKrXuyG30EsQI86YP3Xjf0T7XzR73hD6FDgknfh3GWA4l0eEwcS2BRTleFC06aqSXq8SErczAj3nCjkVJBrKwONd47LxOnaYjxzAsbE+R1duIdiMLuxZ7/nTrwl8e6Sv+VSDv4e7qUzD0R/irv5Ne30PR9OG8aQgHBNMWBztkJz0VcCathlYE4AtPyby1PBEs/4V0S3Ps/ESlpdUQRqaW10Jb0P6Iy0Kn9L57JlSzfsyhcNmJ9hAAM28xyXTGaGVF8ZibqZBgsmJierh6jspeG+zWU1h5yYdIRj9QMP7lWu4njBxjUFLneWEcKD9rE0nnCfDasbzXtfSQyaUIrC+s67GMHY+YgUil7tQq9GuU2O7v4iGSdbpnlai1p8zUzVMavrUVfA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(36756003)(2906002)(107886003)(5660300002)(26005)(186003)(83380400001)(6916009)(4326008)(2616005)(1076003)(8936002)(44832011)(6486002)(30864003)(38350700002)(38100700002)(508600001)(86362001)(316002)(6666004)(52116002)(8676002)(66556008)(66476007)(66946007)(6506007)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0A/JQD9KDuPiIgZzqUU3Dv4OssL+np9JCYQc4NhmHsDIFe9CMl6XL2EoBOq5edOAurgWDQFNqWTPylrsrX5KnBYg3X+3egQnjvYptXu0c8ayAnBdBQ7GmObT9OIMqAMIVB0ozZdA5Ji8hybYHNffgqg65dtT7PC54xWvzGFRUw8JshfK/xvB4Unv1H9zcHZpA3vaUfbItLxGGLPEx9M/CMCTOGsXctCPcRdjBsSnKf0HWRyCbipgP3Un02QvUEMA/LWJ62NuzGnQTP/aHx5cHHjaF9RHOTFlEHBg5lP+5zd9d3tivhkBsQC2CEkLgwqBZQHW7sSBHK1JT36O1I6bwVSdDxSBtiTm2Z0OMtWsCn0wsTUwtwqh4Fma1p/G/9nlx/i7Ln/E/GIufTVMn9n7V+rgbVpz2pgSbd7pP8gUCFroH+YPJsdooMeZO4VzbscYZRRg97qSAWFzkCHHrvPtcx/wDYnyctS6XzAHwid4ZmEV6tZ4myJerfmsGoAASn6LkxoQHp/uBlkEzCDtMpLlT4R6ozcQIx2+v5YiSbeSXcovmXCHvZzB2Neb4qSr0AYRVSmou++HViwl46B8HuOTrCZBQA8wt3Hq2JoPIXLfaju9doSyouA8GtUWWOcK3z4OS1FunM1aHOL3LGOTEkcpi+3pXJnNo7GjxifjNohoSo5v67mUGAMeBa+B3j0Jf0nf9PA9gFDM10D7p1F0U8f4hu72QpMYkltM/+aNjLQJZtwkxSqWOnvJRrYoxlZNkE4TuQ0bN1AhXWmwEyZN7PhsdOUvQ3k7B2JOaDXSwR5sCFOgvcGNAGZEDpFRqCxHOUe7BNdDBJ32VcwDcer8ujHT/Aw6aU6dAN2iOMqUJWLwa+F+HEEBkKysuucd54Zm1xBl7RXrBvZSgfsCb7SIF4uOD+4EKzP/qtgxS4Y60c/Yg0UL0GKfS/JPCO5w25EyZLT72Z6UY8EQi7Z38h0IzlBwUn79Z1L6s898mvnrBks0wPL43FAGFJrf13b5Z95qm04jegmRe9yxI70FDPvkXg0MbnBj3Hfy4Hkp4h0qwRLsG3xwCA8rv01jEBXiO4LDi5XrbIhJ8NglkskvbeEHijqIGlm1HE1+pzFjQUv/q7fZzJBcNVCmfKHrH/dwf/45DbponjI/ThZSPNj3VNcJK7F4ZjBVtNsw/lNJYv/x8PG8LG4HmzQbdwYmCwKGAFgj8efHqxwrZpBe3sy7csZFS4eM/pf8PBOjUHTUQcnMaGn4q4D/S4trTqDTTZ8UG9uWX+4PFPLzSS/huvN7dzcfAVqdVM94v/6A19UhyFoQ5dMdwCtkL7vS3oC9odEJIQxCv4Iyk8UD9XYMHjXff+ZbmLKuVTFPQB88BlWGvt4XmFcza9D/lJhAYxGnwnTVzHjvNWUfKvCdcvhaGGYoKnM5WhZ/aWwL5EwGzZBcDMElEr0dJ/NKB0fcxqGnuBBHWpY/95DIv2zpLmiCV8yZwANpTt0joZf8PGXNj0QNNSS92PBrAHg+q6ZZiiS6QlCGigEzjUVggpqPwyiOprK5sNTDLjQMFzyifwIULI5rVh9dmFQ7CQRioD6jLIuOjKNuI4+8+j1egXhUTXWgq3FaEkQ30KvGTCH9kTVRD4KT2qsI2pebDhZ7+r5yh6tHSpL85jB0D1SwfVH6ngwwmoDov+Wx8Nh5LEQgNdhrc9FeM7BXeWuc3rI= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: 979bc3e3-edaf-48f9-1afa-08d9fe4f584f X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2022 02:24:58.8648 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 23b57807-562f-49ad-92c4-3bb0f07a1fdf X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dmHh7Z/SXBaLcPf6tsh8JuXLww3YitCt/qx+9+U3tO1FY2FGx0elB84uC+6PeP/MbPzOHKxw5ifweqeD1vBGviZ+Wb4LpL2ayGQQ5osDJ4U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YTBPR01MB3184 X-Proofpoint-ORIG-GUID: tzWceT-HM_rcVZ3vN4MGYjfbeC0vBNDo X-Proofpoint-GUID: tzWceT-HM_rcVZ3vN4MGYjfbeC0vBNDo X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-04_09,2022-03-04_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 mlxscore=0 malwarescore=0 impostorscore=0 clxscore=1015 priorityscore=1501 adultscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203050007 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220304_182517_003277_34B90B27 X-CRM114-Status: GOOD ( 19.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Simplify the DMA error handling process, and remove some duplicated code between the DMA error handling and the stop function. Signed-off-by: Robert Hancock --- .../net/ethernet/xilinx/xilinx_axienet_main.c | 280 +++++++----------- 1 file changed, 105 insertions(+), 175 deletions(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 5a1ffdf9d8f7..d705b62c3958 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -226,6 +226,44 @@ static void axienet_dma_bd_release(struct net_device *ndev) lp->rx_bd_p); } +/** + * axienet_dma_start - Set up DMA registers and start DMA operation + * @lp: Pointer to the axienet_local structure + */ +static void axienet_dma_start(struct axienet_local *lp) +{ + u32 rx_cr, tx_cr; + + /* Start updating the Rx channel control register */ + rx_cr = (lp->coalesce_count_rx << XAXIDMA_COALESCE_SHIFT) | + (XAXIDMA_DFT_RX_WAITBOUND << XAXIDMA_DELAY_SHIFT) | + XAXIDMA_IRQ_ALL_MASK; + axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, rx_cr); + + /* Start updating the Tx channel control register */ + tx_cr = (lp->coalesce_count_tx << XAXIDMA_COALESCE_SHIFT) | + (XAXIDMA_DFT_TX_WAITBOUND << XAXIDMA_DELAY_SHIFT) | + XAXIDMA_IRQ_ALL_MASK; + axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, tx_cr); + + /* Populate the tail pointer and bring the Rx Axi DMA engine out of + * halted state. This will make the Rx side ready for reception. + */ + axienet_dma_out_addr(lp, XAXIDMA_RX_CDESC_OFFSET, lp->rx_bd_p); + rx_cr |= XAXIDMA_CR_RUNSTOP_MASK; + axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, rx_cr); + axienet_dma_out_addr(lp, XAXIDMA_RX_TDESC_OFFSET, lp->rx_bd_p + + (sizeof(*lp->rx_bd_v) * (lp->rx_bd_num - 1))); + + /* Write to the RS (Run-stop) bit in the Tx channel control register. + * Tx channel is now ready to run. But only after we write to the + * tail pointer register that the Tx channel will start transmitting. + */ + axienet_dma_out_addr(lp, XAXIDMA_TX_CDESC_OFFSET, lp->tx_bd_p); + tx_cr |= XAXIDMA_CR_RUNSTOP_MASK; + axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, tx_cr); +} + /** * axienet_dma_bd_init - Setup buffer descriptor rings for Axi DMA * @ndev: Pointer to the net_device structure @@ -238,7 +276,6 @@ static void axienet_dma_bd_release(struct net_device *ndev) */ static int axienet_dma_bd_init(struct net_device *ndev) { - u32 cr; int i; struct sk_buff *skb; struct axienet_local *lp = netdev_priv(ndev); @@ -296,50 +333,7 @@ static int axienet_dma_bd_init(struct net_device *ndev) lp->rx_bd_v[i].cntrl = lp->max_frm_size; } - /* Start updating the Rx channel control register */ - cr = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET); - /* Update the interrupt coalesce count */ - cr = ((cr & ~XAXIDMA_COALESCE_MASK) | - ((lp->coalesce_count_rx) << XAXIDMA_COALESCE_SHIFT)); - /* Update the delay timer count */ - cr = ((cr & ~XAXIDMA_DELAY_MASK) | - (XAXIDMA_DFT_RX_WAITBOUND << XAXIDMA_DELAY_SHIFT)); - /* Enable coalesce, delay timer and error interrupts */ - cr |= XAXIDMA_IRQ_ALL_MASK; - /* Write to the Rx channel control register */ - axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr); - - /* Start updating the Tx channel control register */ - cr = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET); - /* Update the interrupt coalesce count */ - cr = (((cr & ~XAXIDMA_COALESCE_MASK)) | - ((lp->coalesce_count_tx) << XAXIDMA_COALESCE_SHIFT)); - /* Update the delay timer count */ - cr = (((cr & ~XAXIDMA_DELAY_MASK)) | - (XAXIDMA_DFT_TX_WAITBOUND << XAXIDMA_DELAY_SHIFT)); - /* Enable coalesce, delay timer and error interrupts */ - cr |= XAXIDMA_IRQ_ALL_MASK; - /* Write to the Tx channel control register */ - axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr); - - /* Populate the tail pointer and bring the Rx Axi DMA engine out of - * halted state. This will make the Rx side ready for reception. - */ - axienet_dma_out_addr(lp, XAXIDMA_RX_CDESC_OFFSET, lp->rx_bd_p); - cr = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET); - axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, - cr | XAXIDMA_CR_RUNSTOP_MASK); - axienet_dma_out_addr(lp, XAXIDMA_RX_TDESC_OFFSET, lp->rx_bd_p + - (sizeof(*lp->rx_bd_v) * (lp->rx_bd_num - 1))); - - /* Write to the RS (Run-stop) bit in the Tx channel control register. - * Tx channel is now ready to run. But only after we write to the - * tail pointer register that the Tx channel will start transmitting. - */ - axienet_dma_out_addr(lp, XAXIDMA_TX_CDESC_OFFSET, lp->tx_bd_p); - cr = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET); - axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, - cr | XAXIDMA_CR_RUNSTOP_MASK); + axienet_dma_start(lp); return 0; out: @@ -530,6 +524,44 @@ static int __axienet_device_reset(struct axienet_local *lp) return 0; } +/** + * axienet_dma_stop - Stop DMA operation + * @lp: Pointer to the axienet_local structure + */ +static void axienet_dma_stop(struct axienet_local *lp) +{ + int count; + u32 cr, sr; + + cr = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET); + cr &= ~(XAXIDMA_CR_RUNSTOP_MASK | XAXIDMA_IRQ_ALL_MASK); + axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr); + synchronize_irq(lp->rx_irq); + + cr = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET); + cr &= ~(XAXIDMA_CR_RUNSTOP_MASK | XAXIDMA_IRQ_ALL_MASK); + axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr); + synchronize_irq(lp->tx_irq); + + /* Give DMAs a chance to halt gracefully */ + sr = axienet_dma_in32(lp, XAXIDMA_RX_SR_OFFSET); + for (count = 0; !(sr & XAXIDMA_SR_HALT_MASK) && count < 5; ++count) { + msleep(20); + sr = axienet_dma_in32(lp, XAXIDMA_RX_SR_OFFSET); + } + + sr = axienet_dma_in32(lp, XAXIDMA_TX_SR_OFFSET); + for (count = 0; !(sr & XAXIDMA_SR_HALT_MASK) && count < 5; ++count) { + msleep(20); + sr = axienet_dma_in32(lp, XAXIDMA_TX_SR_OFFSET); + } + + /* Do a reset to ensure DMA is really stopped */ + axienet_lock_mii(lp); + __axienet_device_reset(lp); + axienet_unlock_mii(lp); +} + /** * axienet_device_reset - Reset and initialize the Axi Ethernet hardware. * @ndev: Pointer to the net_device structure @@ -949,41 +981,27 @@ static void axienet_recv(struct net_device *ndev) */ static irqreturn_t axienet_tx_irq(int irq, void *_ndev) { - u32 cr; unsigned int status; struct net_device *ndev = _ndev; struct axienet_local *lp = netdev_priv(ndev); status = axienet_dma_in32(lp, XAXIDMA_TX_SR_OFFSET); - if (status & (XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_DELAY_MASK)) { - axienet_dma_out32(lp, XAXIDMA_TX_SR_OFFSET, status); - axienet_start_xmit_done(lp->ndev); - goto out; - } + if (!(status & XAXIDMA_IRQ_ALL_MASK)) return IRQ_NONE; - if (status & XAXIDMA_IRQ_ERROR_MASK) { - dev_err(&ndev->dev, "DMA Tx error 0x%x\n", status); - dev_err(&ndev->dev, "Current BD is at: 0x%x%08x\n", - (lp->tx_bd_v[lp->tx_bd_ci]).phys_msb, - (lp->tx_bd_v[lp->tx_bd_ci]).phys); - - cr = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET); - /* Disable coalesce, delay timer and error interrupts */ - cr &= (~XAXIDMA_IRQ_ALL_MASK); - /* Write to the Tx channel control register */ - axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr); - - cr = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET); - /* Disable coalesce, delay timer and error interrupts */ - cr &= (~XAXIDMA_IRQ_ALL_MASK); - /* Write to the Rx channel control register */ - axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr); + axienet_dma_out32(lp, XAXIDMA_TX_SR_OFFSET, status); + + if (unlikely(status & XAXIDMA_IRQ_ERROR_MASK)) { + netdev_err(ndev, "DMA Tx error 0x%x\n", status); + netdev_err(ndev, "Current BD is at: 0x%x%08x\n", + (lp->tx_bd_v[lp->tx_bd_ci]).phys_msb, + (lp->tx_bd_v[lp->tx_bd_ci]).phys); schedule_work(&lp->dma_err_task); - axienet_dma_out32(lp, XAXIDMA_TX_SR_OFFSET, status); + } else { + axienet_start_xmit_done(lp->ndev); } -out: + return IRQ_HANDLED; } @@ -999,41 +1017,27 @@ static irqreturn_t axienet_tx_irq(int irq, void *_ndev) */ static irqreturn_t axienet_rx_irq(int irq, void *_ndev) { - u32 cr; unsigned int status; struct net_device *ndev = _ndev; struct axienet_local *lp = netdev_priv(ndev); status = axienet_dma_in32(lp, XAXIDMA_RX_SR_OFFSET); - if (status & (XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_DELAY_MASK)) { - axienet_dma_out32(lp, XAXIDMA_RX_SR_OFFSET, status); - axienet_recv(lp->ndev); - goto out; - } + if (!(status & XAXIDMA_IRQ_ALL_MASK)) return IRQ_NONE; - if (status & XAXIDMA_IRQ_ERROR_MASK) { - dev_err(&ndev->dev, "DMA Rx error 0x%x\n", status); - dev_err(&ndev->dev, "Current BD is at: 0x%x%08x\n", - (lp->rx_bd_v[lp->rx_bd_ci]).phys_msb, - (lp->rx_bd_v[lp->rx_bd_ci]).phys); - - cr = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET); - /* Disable coalesce, delay timer and error interrupts */ - cr &= (~XAXIDMA_IRQ_ALL_MASK); - /* Finally write to the Tx channel control register */ - axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr); - - cr = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET); - /* Disable coalesce, delay timer and error interrupts */ - cr &= (~XAXIDMA_IRQ_ALL_MASK); - /* write to the Rx channel control register */ - axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr); + axienet_dma_out32(lp, XAXIDMA_RX_SR_OFFSET, status); + + if (unlikely(status & XAXIDMA_IRQ_ERROR_MASK)) { + netdev_err(ndev, "DMA Rx error 0x%x\n", status); + netdev_err(ndev, "Current BD is at: 0x%x%08x\n", + (lp->rx_bd_v[lp->rx_bd_ci]).phys_msb, + (lp->rx_bd_v[lp->rx_bd_ci]).phys); schedule_work(&lp->dma_err_task); - axienet_dma_out32(lp, XAXIDMA_RX_SR_OFFSET, status); + } else { + axienet_recv(lp->ndev); } -out: + return IRQ_HANDLED; } @@ -1151,8 +1155,6 @@ static int axienet_open(struct net_device *ndev) */ static int axienet_stop(struct net_device *ndev) { - u32 cr, sr; - int count; struct axienet_local *lp = netdev_priv(ndev); dev_dbg(&ndev->dev, "axienet_close()\n"); @@ -1163,34 +1165,10 @@ static int axienet_stop(struct net_device *ndev) axienet_setoptions(ndev, lp->options & ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN)); - cr = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET); - cr &= ~(XAXIDMA_CR_RUNSTOP_MASK | XAXIDMA_IRQ_ALL_MASK); - axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr); - - cr = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET); - cr &= ~(XAXIDMA_CR_RUNSTOP_MASK | XAXIDMA_IRQ_ALL_MASK); - axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr); + axienet_dma_stop(lp); axienet_iow(lp, XAE_IE_OFFSET, 0); - /* Give DMAs a chance to halt gracefully */ - sr = axienet_dma_in32(lp, XAXIDMA_RX_SR_OFFSET); - for (count = 0; !(sr & XAXIDMA_SR_HALT_MASK) && count < 5; ++count) { - msleep(20); - sr = axienet_dma_in32(lp, XAXIDMA_RX_SR_OFFSET); - } - - sr = axienet_dma_in32(lp, XAXIDMA_TX_SR_OFFSET); - for (count = 0; !(sr & XAXIDMA_SR_HALT_MASK) && count < 5; ++count) { - msleep(20); - sr = axienet_dma_in32(lp, XAXIDMA_TX_SR_OFFSET); - } - - /* Do a reset to ensure DMA is really stopped */ - axienet_lock_mii(lp); - __axienet_device_reset(lp); - axienet_unlock_mii(lp); - cancel_work_sync(&lp->dma_err_task); if (lp->eth_irq > 0) @@ -1709,22 +1687,17 @@ static const struct phylink_mac_ops axienet_phylink_ops = { */ static void axienet_dma_err_handler(struct work_struct *work) { + u32 i; u32 axienet_status; - u32 cr, i; + struct axidma_bd *cur_p; struct axienet_local *lp = container_of(work, struct axienet_local, dma_err_task); struct net_device *ndev = lp->ndev; - struct axidma_bd *cur_p; axienet_setoptions(ndev, lp->options & ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN)); - /* When we do an Axi Ethernet reset, it resets the complete core - * including the MDIO. MDIO must be disabled before resetting. - * Hold MDIO bus lock to avoid MDIO accesses during the reset. - */ - axienet_lock_mii(lp); - __axienet_device_reset(lp); - axienet_unlock_mii(lp); + + axienet_dma_stop(lp); for (i = 0; i < lp->tx_bd_num; i++) { cur_p = &lp->tx_bd_v[i]; @@ -1764,50 +1737,7 @@ static void axienet_dma_err_handler(struct work_struct *work) lp->tx_bd_tail = 0; lp->rx_bd_ci = 0; - /* Start updating the Rx channel control register */ - cr = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET); - /* Update the interrupt coalesce count */ - cr = ((cr & ~XAXIDMA_COALESCE_MASK) | - (XAXIDMA_DFT_RX_THRESHOLD << XAXIDMA_COALESCE_SHIFT)); - /* Update the delay timer count */ - cr = ((cr & ~XAXIDMA_DELAY_MASK) | - (XAXIDMA_DFT_RX_WAITBOUND << XAXIDMA_DELAY_SHIFT)); - /* Enable coalesce, delay timer and error interrupts */ - cr |= XAXIDMA_IRQ_ALL_MASK; - /* Finally write to the Rx channel control register */ - axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr); - - /* Start updating the Tx channel control register */ - cr = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET); - /* Update the interrupt coalesce count */ - cr = (((cr & ~XAXIDMA_COALESCE_MASK)) | - (XAXIDMA_DFT_TX_THRESHOLD << XAXIDMA_COALESCE_SHIFT)); - /* Update the delay timer count */ - cr = (((cr & ~XAXIDMA_DELAY_MASK)) | - (XAXIDMA_DFT_TX_WAITBOUND << XAXIDMA_DELAY_SHIFT)); - /* Enable coalesce, delay timer and error interrupts */ - cr |= XAXIDMA_IRQ_ALL_MASK; - /* Finally write to the Tx channel control register */ - axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr); - - /* Populate the tail pointer and bring the Rx Axi DMA engine out of - * halted state. This will make the Rx side ready for reception. - */ - axienet_dma_out_addr(lp, XAXIDMA_RX_CDESC_OFFSET, lp->rx_bd_p); - cr = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET); - axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, - cr | XAXIDMA_CR_RUNSTOP_MASK); - axienet_dma_out_addr(lp, XAXIDMA_RX_TDESC_OFFSET, lp->rx_bd_p + - (sizeof(*lp->rx_bd_v) * (lp->rx_bd_num - 1))); - - /* Write to the RS (Run-stop) bit in the Tx channel control register. - * Tx channel is now ready to run. But only after we write to the - * tail pointer register that the Tx channel will start transmitting - */ - axienet_dma_out_addr(lp, XAXIDMA_TX_CDESC_OFFSET, lp->tx_bd_p); - cr = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET); - axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, - cr | XAXIDMA_CR_RUNSTOP_MASK); + axienet_dma_start(lp); axienet_status = axienet_ior(lp, XAE_RCW1_OFFSET); axienet_status &= ~XAE_RCW1_RX_MASK; From patchwork Sat Mar 5 02:24:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12770231 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6126DC433F5 for ; Sat, 5 Mar 2022 02:27:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QjpPdY72v5TCMgwPXLLS7sUFQINTaYkryP6os+fHwB8=; b=4AF0g2z87/QNuh DfsyfvtbZCRdMv1DLFMCZAeJs8VN3FGqQ4OvUFs2Fo9sD/yXv4LjGRuf+5EF4EokGia/vRDOHsFNR SZXHckjD2X5cdAbG0mkPZ3eq+I5NRI7e515PzRcZkdU+cxbvaUWzhYHlomoS50chFetgPLFoY0FO4 jE2iXXwKD9MimjwIT4IHLdCQ7rYMmilbukHdxyUu9ZGFuhEzcJk5UlPDCfLSvocPYFJttVbK+LBWn LnsH3dUhBeAl/VRp+VqdTaR80Ngl/+w/Voxbu4kgnZBUXBK1vAN821y5pvTZYEnuKqTFj6akZJqGI YuoXI9MU87XScUZxItVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQK7G-00CagE-Rf; Sat, 05 Mar 2022 02:25:55 +0000 Received: from mx0d-0054df01.pphosted.com ([67.231.150.19]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQK6f-00CaUf-Af for linux-arm-kernel@lists.infradead.org; Sat, 05 Mar 2022 02:25:18 +0000 Received: from pps.filterd (m0209000.ppops.net [127.0.0.1]) by mx0c-0054df01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 22524xXq004654; Fri, 4 Mar 2022 21:25:01 -0500 Received: from can01-qb1-obe.outbound.protection.outlook.com (mail-qb1can01lp2054.outbound.protection.outlook.com [104.47.60.54]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3ek4hy8qh4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Mar 2022 21:25:01 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QErzwdhDo9bqsDzBXCY3dJ2riorFPd0itJ71NwxaCzUCd8DyD8+GL4zNWx9GEapD5dZYDHy0VhD7kTCAX6q6IvZt8S43amVNl1tYIH3FurDPibOlKPH5Nvz82q2lnmQNXL5GhPvU3h0LoaJL1Y3x99OIXzIT24Ayw35aXMUguwvUKcvmh+ZPT8dwtAcIx2AbQ+hbzhU/URu/grRvFNn8nVeyvd1f39mCdVUnX2CeTXA5PQjUdWYEk6siyjrKat0VAq+qTzHBQija3nlhB/nsvNl5DpPMwWMlILb5rVCnd+6wSWMzx//Kz05/FphUThtQsECDICCIjbt1qe+NdldnpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LmGF+PECeuzxRb/Bym8EaMgnscDUXKqiVlYkBMd5pHc=; b=nui4CyG1wn5S9euckrarGeJmn8JjetSfvt/fa5rv7Nfdiqevc65eYWRTRlFFhjQQgDfxkT3MQa3TrQRSGSUBjsplxq9a6avK3fcdOs3fGvN1noXVBZ5Nnie0KEj5fOv4q61hYcT558jx2WGyMTWM6cxIAGQk9c0gTzyw4wRGKNwZbhgk5Dvw7czY5V3HYnY3cdEroLvGX2H29l5hUTR5XiBNje6ZZhm1PCNIqTEFLLrH60aRSM+Lp2npYeZMh3kLOtwXALKVI0+74niOs3Zhm0dUD9DD9Bxk9dtZgYVOYEYVrdAIbA1Vwbws7WD+9aFYibQSORMRLbvUfHc2/VaiDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=calian.com; dmarc=pass action=none header.from=calian.com; dkim=pass header.d=calian.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=calian.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LmGF+PECeuzxRb/Bym8EaMgnscDUXKqiVlYkBMd5pHc=; b=JAM5i4fih9JYoAcB/HeOPAPhGJDC8BP3+HggCVH3NbmPJD4zTFU3a0anc1M4fBIq2jgVDevgiKXifqX08zxxgafMZxSmIbtZvom9xrkq7OiP6Rt8PEDyfTpGnbeQX23DDJfa6vNe5McBGT2xuMFDl+d0BzImiqEVXD7+zVgxZUY= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (10.167.1.243) by YTBPR01MB3184.CANPRD01.PROD.OUTLOOK.COM (10.255.47.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Sat, 5 Mar 2022 02:25:00 +0000 Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::e8a8:1158:905f:8230]) by YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::e8a8:1158:905f:8230%7]) with mapi id 15.20.5038.017; Sat, 5 Mar 2022 02:25:00 +0000 From: Robert Hancock To: netdev@vger.kernel.org Cc: radhey.shyam.pandey@xilinx.com, davem@davemloft.net, kuba@kernel.org, michal.simek@xilinx.com, linux@armlinux.org.uk, daniel@iogearbox.net, linux-arm-kernel@lists.infradead.org, Robert Hancock Subject: [PATCH net-next v3 4/7] net: axienet: don't set IRQ timer when IRQ delay not used Date: Fri, 4 Mar 2022 20:24:40 -0600 Message-Id: <20220305022443.2708763-5-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220305022443.2708763-1-robert.hancock@calian.com> References: <20220305022443.2708763-1-robert.hancock@calian.com> X-ClientProxiedBy: MW4PR03CA0304.namprd03.prod.outlook.com (2603:10b6:303:dd::9) To YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1b0ec5f1-4808-42a1-c0d9-08d9fe4f5912 X-MS-TrafficTypeDiagnostic: YTBPR01MB3184:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y664+KSzNNsNTqvL99o/O7Kw0CU3D4fvp6a6f7iYCvD2w4/UOh4Peqsgt9zDFA5hoK0xn8qDt1ltliVDLCTz0ggA0w9dtmXSJDdT1iL6YKX4IYeMrc9tvSHc3Qk4F18L9ODw+WyDcIHRuQWBJ+G+NA4A+GDQVAuCD9aIZ+8QiBSKz+CrdVnItiZDAsMXM8kYCr+k9kk7OytFUa/J0bMfsxn2em6oa1H2daFRquiePhJnFq0xwSuN954CdK4wMXy+I0zwmOYKUItBL9236Jjz3w6Ww5Q7scGXHdJq7XSM2Gngeg0WwZ0WWgAr9VRTOxhx0J8hyEIx0wp7lw+FAUrnmk6Vm/92g0Irqx2SWflFkC2wmqVEF/o8KSjLA2/9zdcP54Uv+za54UsLEdAJDGS++k5GQLT+/vgGlk8hF2yEoymjEiVtsuiluKWirfBI15jLDwMVnVEaOmSBay2zmmhQcYtgGKiXfi38DdcbV5PC1+2de+zfyKhQEYlPMAB+QPS1Eg49U6/JQBx4CE944099YQtg1TwkbBkV3ZvZV/iyyZFQPCNTa9mIM6r3b8c14Tj9Ybch4gJicHx3TUN/pXB5pT+LeGgEU6YQvpDBI6buEW/ceZL4z8guMMetWFQTebm81rzkJ0mbuJaI1ATAr5x+tl0vOm5mJ+4OU2vVWoML6M0ZzrB8eA5Nsfo8mbvPBfPVP8OWYQ2Zv1Hz6wcW0OQT3w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(36756003)(2906002)(107886003)(5660300002)(26005)(186003)(83380400001)(6916009)(4326008)(2616005)(1076003)(8936002)(44832011)(6486002)(38350700002)(38100700002)(508600001)(86362001)(316002)(6666004)(52116002)(8676002)(66556008)(66476007)(66946007)(6506007)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IsNsz2baAdQbZM/55fKZRKftrs04P+NzbtD0SBhrL5EPpYKPyn5moswAJWyVjJU7nwjc7CXACukwXhpfBybbO7HuE7qzzFINeb5ld3RRBexd0hBGFFWApkTa3bWEZypLUtAYLHqbHjSiaB3J4Jy6DMvYT8M7ivqttYotDcKTkzxcIyOIiY0ZMwQsTUFQjcwqMzvsarjJOGUVOLgGBZ+wqsF7m9Bfl8EDfJi4ow3bZhHnSAltqLwvD7bYfpKiek0HbNmQTQ99mAGUyLvnQM2pTHC5oKrh4XqiOUxQfbOuBOEzUu5ORR0TUnr6Jm5r+BTiU6xypgx5rAZbtZ6QUCF8b7M/156Px58KgoSLS+Zsq0o/BzOff9QNFnsrliwcO7PpGskHEG6Utpt4TQHUIbvCizP4eBt78Hp5OVOHLPNNxHNCScfYyHVZJlmt7z71OafFDWyE061Pb3PybxDEP0CJWOQXph3Z82Ggipv0j0xxdDCkc8/vjiRZoDEiv9fWOeE96mo+W4k7sPR7RX5C7U3pizByxKqsRVezocls4F62qAsvFUndlpJ4FAhlEg2thxMfQ+xU+Xr3l1ezNdF6mzZGRImlQ3pEbq0IopXXupoHtmG3Dv3cmyA2F/tIKwZDagEQwSYJIBb4r4zr4LYIt7JTmHn3gfu3SFSOrxXpAbVRL829r4hfPeal+haw8dXOcyKJzaEz4iQEpywiJkEawlRkDE4jHsNM9+dmUUpBcBz2ni4M1TOUDO5pegplLJL7czN//ew1zofcurGt/wHVqCWdEg3XdPoiSJs5NBnPi7aGq4XYUfor4TpV5RhbfZ4HOSJOKf0pE/DMUnS1fIgNLi0fq/M8Y4pBkDVFN3jq/ea5RUaYdaAXOQfxgc9zxi+rCsibGvDCwNcl9OQLbZE0Pqv882MNz+mKfBQBWizGG5vWkPuQ4t95tBnOxEZxH4RsjedAz3AovwayQq/YqC4IB+GJmVYFR+weX9QZzAcI+TiW+bOiDOi+bDQvUhUZAfkn+BXtCNztyJcyAxguX2ke/QBudbaNpxoa4DG/hJbSJR4zs1qGmYEz3/kfvhYedCumXmowT/dH4lQrYS7NHjvwG5VJRMdKMYSQ3NreGsduvCeK+DyOHVL1bU0UjqMZsfiTThX2XuolTqKNDUKS3A65Ykpzin2pLTuacTVsPb9/oo4SzEsqJsOZM15zNmut3ZhTUAKRS76SyKy5KRuGINQlEGur60P0YMfA/i4JhtlDzX+483UUAepZjEQLdHecLuSZkHkiqIomzS8nNu2VxoCeUITHlreQhLmLrQvSz5UGkk6Ip3WwBGArKxEtKxZZKhxQjs4ifsfdmCPiUtLP9bflCbbNgJRhV3r3cy140VvzXv1NIpbd9ndympEi9Ghfw4Hcgnou9bVIpz7E2FB4/sc6coYoE3UcDwAs4XJs6dHPz2dren0Qyag0EgTv/fLSwKk4N2MvTlMfbg/M+AzgWcGRg2WyRp7lUs0r8iP03dQFU9erM+ALGo2zRvCpUnuBgTCjOCL3/PqPxfW5txXrCLCwOUWwmZIZ5qipfjYO0krOV3Ns99ju5jIxAfNQ5sG68TNstejiMIViIX5RDpZ/K9JkDtkPzkbIwFHCwLThaC9IJbL8v4mMIEwewF2ZACuzAyIE4qKPRldheSuDzfxnBVOaFJB7opI8B9QKXl2HpD367V+C8Oc= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1b0ec5f1-4808-42a1-c0d9-08d9fe4f5912 X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2022 02:25:00.1159 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 23b57807-562f-49ad-92c4-3bb0f07a1fdf X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: JKRxKNMLBijfZ//65A9mSzBdNhMbnl6JFwIbGgjIs4hf9J/7ytps7rKQe4HugicJEoQC3LSXQyS8fHsc9pLyl70JAc+1mxiOcdNnPkolJ0Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YTBPR01MB3184 X-Proofpoint-ORIG-GUID: TW2GYK-UbEkt428WuF424NyFBbbBSBmX X-Proofpoint-GUID: TW2GYK-UbEkt428WuF424NyFBbbBSBmX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-04_09,2022-03-04_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 mlxscore=0 malwarescore=0 impostorscore=0 clxscore=1015 priorityscore=1501 adultscore=0 mlxlogscore=854 phishscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203050007 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220304_182517_512451_80783DA4 X-CRM114-Status: GOOD ( 12.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When the RX or TX coalesce count is set to 1, there's no point in setting the delay timer value since an interrupt will already be raised on every packet, and the delay interrupt just causes extra pointless interrupts. Signed-off-by: Robert Hancock --- .../net/ethernet/xilinx/xilinx_axienet_main.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index d705b62c3958..b374800279e7 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -236,14 +236,24 @@ static void axienet_dma_start(struct axienet_local *lp) /* Start updating the Rx channel control register */ rx_cr = (lp->coalesce_count_rx << XAXIDMA_COALESCE_SHIFT) | - (XAXIDMA_DFT_RX_WAITBOUND << XAXIDMA_DELAY_SHIFT) | - XAXIDMA_IRQ_ALL_MASK; + XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_ERROR_MASK; + /* Only set interrupt delay timer if not generating an interrupt on + * the first RX packet. Otherwise leave at 0 to disable delay interrupt. + */ + if (lp->coalesce_count_rx > 1) + rx_cr |= (XAXIDMA_DFT_RX_WAITBOUND << XAXIDMA_DELAY_SHIFT) | + XAXIDMA_IRQ_DELAY_MASK; axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, rx_cr); /* Start updating the Tx channel control register */ tx_cr = (lp->coalesce_count_tx << XAXIDMA_COALESCE_SHIFT) | - (XAXIDMA_DFT_TX_WAITBOUND << XAXIDMA_DELAY_SHIFT) | - XAXIDMA_IRQ_ALL_MASK; + XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_ERROR_MASK; + /* Only set interrupt delay timer if not generating an interrupt on + * the first TX packet. Otherwise leave at 0 to disable delay interrupt. + */ + if (lp->coalesce_count_tx > 1) + tx_cr |= (XAXIDMA_DFT_TX_WAITBOUND << XAXIDMA_DELAY_SHIFT) | + XAXIDMA_IRQ_DELAY_MASK; axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, tx_cr); /* Populate the tail pointer and bring the Rx Axi DMA engine out of From patchwork Sat Mar 5 02:24:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12770234 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C4569C433EF for ; Sat, 5 Mar 2022 02:29:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TNOe27HUqAkLfdVN34ssm+m0o5HK175l5SigqjWvCok=; b=154BR0OnbMw6pO ANN/uTcVTGq+e62ljV1+Bq+MFZqB14AlxnKxdbaphj9yias38mItl+PCQO1WhNJuVRmJC2DN6sAXE 0kJA5P4Mhfp7iVR/aFnamjYQ7Q4eWDqWVPUnm+1MT2VKJ8r2ZjeuTR8okwAsTOjwm6T1q28lpgPUP w4C3FOg3097u0qP+NSybVJXXg7bpOWD2uUI46L1AzpO93dOktVSSF/V/wtX87qI/02Pa6PKcbnl7+ J3S/GxzgIsG6HcWC4LS2gzXaWufjkPC/OdYA15DqVxX6HUfYsq/g1TgOaMTTtaqTDhW0692ouZUHq 0DUKgwEHejGAWbIhcEsQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQK8w-00CbOT-HE; Sat, 05 Mar 2022 02:27:39 +0000 Received: from mx0d-0054df01.pphosted.com ([67.231.150.19]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQK6h-00CaVM-49 for linux-arm-kernel@lists.infradead.org; Sat, 05 Mar 2022 02:25:21 +0000 Received: from pps.filterd (m0209000.ppops.net [127.0.0.1]) by mx0c-0054df01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 22526BSA005431; Fri, 4 Mar 2022 21:25:03 -0500 Received: from can01-qb1-obe.outbound.protection.outlook.com (mail-qb1can01lp2052.outbound.protection.outlook.com [104.47.60.52]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3ek4hy8qh5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Mar 2022 21:25:03 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q300Oa98cheG1TWoAg/XyYzKmKfHr6AujYZSaOu7Vbkgl0aPlhM1F2paOfR2l//59qNJR6lEWxSA5MlMrTlrd2nYGEltBOZAQzD29tLda/Wo9cXF/uvFs9r77O4s37wrqBaNEJi8TaxBVgYNVqXY66/Svt4j3tBc7gq0jSVdzdJvOnPi4Ck7AsZtbQHaNJiiSB4AzoAXnHcZXK8L2T3np2XpVKCqr9jNy43TyBAFZ/1UKauoNmPMHIiNMKDgOa7zJruPtsBYVvTDeNVTUjKiqybTDLm2OxkJfbqPNte3CrWjdWhRPI5OyOp+SJV7dnp9hUCY89YWjiDAamLmQqi7DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3+/J6oXucIYsa77msWCUrXUpK9dfYgzBUL/xyTBcXik=; b=Yo+MR4PAdJg7rriXCQc56gnyfKbUZn+GuYiYwsALPwQyngALb/XF0FfCAbo/LbbS+KZGp6NQviSL1qUqGzGI9DaDIt6tBfpXHxv8GK9cxi8hKf1Gvet3Um8NZac4IR1nbz2DXr3bblz/gqv4DGlLqNi/wKsdh1qQVenIXx0o8KjyKkctBGF5qTeIANpBTJ7A7hRnH/Kn4Uvo+FnoPDRmBgDYbVWxD5HMdtZWd5tdQUWlPxNJwcbhXAmm2FUYmgeypIntXWwyZ8qC4RSSDGR8AZP+Pskvx5DWnH1rrbZnYnqLQG1bhTTImnLCHTVSCIUFTQZf6Sp6iEY6CJhJk2Uevw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=calian.com; dmarc=pass action=none header.from=calian.com; dkim=pass header.d=calian.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=calian.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3+/J6oXucIYsa77msWCUrXUpK9dfYgzBUL/xyTBcXik=; b=nRKtdMJVOevXCOcq2WEWyIk0kI7ra12S+BdihDeQrE0+U7ymATcQ+Xf65o+prM+Hu6RsnE7yZdkwztZX6+35z0tHEsNU0tWY1zTsr7yrkkYwrSyRuATspyxl1/WwpXMxaQinjIQYgYYwFHtSuoxoZDkPYtWD1H5FdjdIxfKufl4= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (10.167.1.243) by YTBPR01MB3184.CANPRD01.PROD.OUTLOOK.COM (10.255.47.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Sat, 5 Mar 2022 02:25:01 +0000 Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::e8a8:1158:905f:8230]) by YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::e8a8:1158:905f:8230%7]) with mapi id 15.20.5038.017; Sat, 5 Mar 2022 02:25:01 +0000 From: Robert Hancock To: netdev@vger.kernel.org Cc: radhey.shyam.pandey@xilinx.com, davem@davemloft.net, kuba@kernel.org, michal.simek@xilinx.com, linux@armlinux.org.uk, daniel@iogearbox.net, linux-arm-kernel@lists.infradead.org, Robert Hancock Subject: [PATCH net-next v3 5/7] net: axienet: implement NAPI and GRO receive Date: Fri, 4 Mar 2022 20:24:41 -0600 Message-Id: <20220305022443.2708763-6-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220305022443.2708763-1-robert.hancock@calian.com> References: <20220305022443.2708763-1-robert.hancock@calian.com> X-ClientProxiedBy: MW4PR03CA0304.namprd03.prod.outlook.com (2603:10b6:303:dd::9) To YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a9b7a242-50c2-440a-04bc-08d9fe4f59d4 X-MS-TrafficTypeDiagnostic: YTBPR01MB3184:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jwWJExK296sc/oPY6IhXukbAmFCHihQZ9YuzC2arATXF4yYh+oIofSGlU28cw3q3JpKgpH9zIoNOxZX1Up3NO6mN7id4wdIl6fkdoyeVp8hlV6jg/VwQ/b1wqdc+A3HRj+Y+65SbgA5Q76WCIbjt3BI/GP9vF5Q5GMohXHLAafnFrQm4Xnlj/78eMxtk/rhJvbHBlB9EV21vUWiAXmo7pRxSbD5JUQRFCQsvfVVWDOEKpXu8UX+BCrJmdXqJyeEquHpYbSzWDcvmzuDMX4UY9UK6/NIXR2s7ysHAUHVq5o05o5KVCeKVVvOkke7D1df2o1bE+ilXlHwwL8FZQzkzG2b97R2NEvhu34nIxMh0P+tQJMGHUfsOOeODVfAr6xv6a5+vsO3rXr5UDV0DRtJfTb63P+zn+3IPiAr94LGXdz6KuGR2GoonTjeGQV5hSlZrlOkz+Cx417JwyxYKGcHQ7QUwD+lRQ3enuHd2IsdwgoxWqDdCskQu8Sq8tfPSgtwhu9T0tCqLXywXzbV4DKuzKxNuGUje0aAPpNmiWETGiamDJkVCuIrATS/CEdnEjyz1AKuMFUpPHSRnyGBkj/DsQJyQyoI+J/z05C/AmNWdoDJ8BVVTLC9UPex+28nhFvMRPuWIdPbauUwF/i++6hEClxW39FskGhzIV8k19VrBrXujs3qA5k/Qc/wFSjrQQ2b0P1ACDhPoXN987OcWvEnpGw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(36756003)(2906002)(107886003)(5660300002)(26005)(186003)(83380400001)(6916009)(4326008)(2616005)(1076003)(8936002)(44832011)(6486002)(38350700002)(38100700002)(508600001)(86362001)(316002)(6666004)(52116002)(8676002)(66556008)(66476007)(66946007)(6506007)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: msmLkhZaHow2t8n7SblX44PnILBgPy9BssDosF6eiL/N5fIdX09VE+Ym+G4plBqXnq35Et8pWW0V576Hb0Q3nr90ObJ17dEocNjuFkwZ3IO+tLAHeDumamk9BWxZblp/JBSsk+cW3RZuWVeW/mJuyXQrky34RiVrgM8CmRRA0+awzTiafmSZIBM1zPwEohRBDNi2rgQEOKTklFRI65fEbCOWa75/251DYdsSNe3SJ38szAB1FdFQ57DCN5OP60jNnYK1QdimOrUk2JZb5rlu2EFgSLMsb0uEVO2Qc/dgbIhmE3+yISjwY5aU027w5EQzR+dcZqLLg1egCRXp1bXLy30FLUI5xuqn4jldW4iHeqo0goc6ujp/FcFVCNfSxnrnxZi9ZNu9SYV7HwslWBlXwctN2C+eo7bfuOIs7g6AoZH+UPju7KWWedhlDn6kB4FofpVwJikLbto5UF0IngX/EIfgc7siRiV1m8yTDHctss4XS7XkUH9guDqlOQ8TeykV++8qqa5izHJiYW58yiqxKvmOI1kA8kInmFawiJQsJkv2H67MH3LdVwJezG+veo72+m7AMCKopklRdmfuTDrIVB7E76iT5hx0Jkm7iLbOoumevICUnLQcO1eaUNSa2LioP23SGKf+bVNi0awnce7wWQlcvgnxSvLm5EyUrmCp+TxffjKWXBybCH/igMB3xNdBCqPwIKA+Fvq1QstBISNTqkmgxq2GMo7ytKRKdtXzywQml9ue8uuSEDPBTpjy8jH9RIUQRs88M4v1ajl4u1p3KcDrut7Viui687ClZRI4IlWYo0OcXspq9o3HIYjwlL3LO8DZjYcQu3e5lSlq7NIXQCMlHER5nlhxJ0cPPUroccozeN26yw6WEFNOqM9lRCRbVIteOe2km0ScbL3kM5vK5+y/w0ycqEyIKQKhHFMd6a6r5KY2xkua6YtGE7wUgJ5zwtTDw0zgyi1s8RgEGvev8jQm3jGeXJohCrXhRmE81Lf2y+7QWidGGBY5xqEKqjPgOnIMaW5gZvLLdix1SuhsxguH1ZHSE+mEN9aLToDKoj3TZIxIpDgQOWTHib37su+VMPrvXZJUowxLDK8jhpSuo8ezg91W/4F8oyEgohbYKMjWe3FeFmg3EGI3TIoyDcNmFluDF4KG0/RTsUFt/DZccD8U2RRyESQq4NizQA1OHibsnHUYzHRiombQ64NdV5nhpYNhX/royosw+vjsgyPAr4LXtfWdFpaIk26Wx0bWzqjyw3V3b560hh7M8OewMUGmvCAhd4M3CjQb9kRgL7lV6EvpRoZZVIpCLV4FSEJTRre/WDZyCmwU9qgJE+WnIPW6pyWcSqnb9Yi2sjXkU4IvMA9IfT/ppTn8VIGuLm4Fo8IdbA3b67kxbTvcCQn2MQeDY+BoWOXP8xwiLeaSZu6jfc/IW9aZeOoS/b5Zu8cGkS1Jm6P+dtJfPJ+yiChn0IXv75CuzGKV5BKPPRXivlgFtF9bbFA4GejH0sEDCAO+b8U9j9iYjDH2HA7jUcvLNYYBRcIBC2g5GVrldVUewi+KOhN6mMJJNnZKeVZXnB8SrwJyV8fnuEPgjBwgPTkyxlwXQLbx6o5Nx3dt/GEZpk75OnRmSToeu8Cz1nBLwE6E8YNTQHyhGtqZciR3y+ZMDdTtibcwRlGMsHNXTs0nYMdkflxqq7dlLM9/nkagjoU+fo0= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: a9b7a242-50c2-440a-04bc-08d9fe4f59d4 X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2022 02:25:01.3980 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 23b57807-562f-49ad-92c4-3bb0f07a1fdf X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: KJBhhHziGOhfwbsd/0RjkiqXQPTd4W8+Q25bxk/7KI4r3x05K8XmU2qNuvgvZxU7DW8Kn5WESJMa3RT1iz28z5PNkzA61LgCM0VOmq93I70= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YTBPR01MB3184 X-Proofpoint-ORIG-GUID: V8Nb_v788XeJ2SIOSFL_ATuTResCF2Q1 X-Proofpoint-GUID: V8Nb_v788XeJ2SIOSFL_ATuTResCF2Q1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-04_09,2022-03-04_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 mlxscore=0 malwarescore=0 impostorscore=0 clxscore=1015 priorityscore=1501 adultscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203050007 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220304_182519_317775_EBE1E3C7 X-CRM114-Status: GOOD ( 20.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Implement NAPI and GRO receive. In addition to better performance, this also avoids handling RX packets in hard IRQ context, which reduces the IRQ latency impact to other devices. Signed-off-by: Robert Hancock --- drivers/net/ethernet/xilinx/xilinx_axienet.h | 6 ++ .../net/ethernet/xilinx/xilinx_axienet_main.c | 81 ++++++++++++------- 2 files changed, 59 insertions(+), 28 deletions(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/ethernet/xilinx/xilinx_axienet.h index 40108968b350..c771827587b3 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet.h +++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h @@ -385,6 +385,7 @@ struct axidma_bd { * @phy_node: Pointer to device node structure * @phylink: Pointer to phylink instance * @phylink_config: phylink configuration settings + * @napi: NAPI control structure * @pcs_phy: Reference to PCS/PMA PHY if used * @pcs: phylink pcs structure for PCS PHY * @switch_x_sgmii: Whether switchable 1000BaseX/SGMII mode is enabled in the core @@ -395,6 +396,7 @@ struct axidma_bd { * @regs_start: Resource start for axienet device addresses * @regs: Base address for the axienet_local device address space * @dma_regs: Base address for the axidma device address space + * @rx_dma_cr: Nominal content of RX DMA control register * @dma_err_task: Work structure to process Axi DMA errors * @tx_irq: Axidma TX IRQ number * @rx_irq: Axidma RX IRQ number @@ -434,6 +436,8 @@ struct axienet_local { struct phylink *phylink; struct phylink_config phylink_config; + struct napi_struct napi; + struct mdio_device *pcs_phy; struct phylink_pcs pcs; @@ -449,6 +453,8 @@ struct axienet_local { void __iomem *regs; void __iomem *dma_regs; + u32 rx_dma_cr; + struct work_struct dma_err_task; int tx_irq; diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index b374800279e7..860ff0447f71 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -7,7 +7,7 @@ * Copyright (c) 2008-2009 Secret Lab Technologies Ltd. * Copyright (c) 2010 - 2011 Michal Simek * Copyright (c) 2010 - 2011 PetaLogix - * Copyright (c) 2019 SED Systems, a division of Calian Ltd. + * Copyright (c) 2019 - 2022 Calian Advanced Technologies * Copyright (c) 2010 - 2012 Xilinx, Inc. All rights reserved. * * This is a driver for the Xilinx Axi Ethernet which is used in the Virtex6 @@ -232,18 +232,18 @@ static void axienet_dma_bd_release(struct net_device *ndev) */ static void axienet_dma_start(struct axienet_local *lp) { - u32 rx_cr, tx_cr; + u32 tx_cr; /* Start updating the Rx channel control register */ - rx_cr = (lp->coalesce_count_rx << XAXIDMA_COALESCE_SHIFT) | - XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_ERROR_MASK; + lp->rx_dma_cr = (lp->coalesce_count_rx << XAXIDMA_COALESCE_SHIFT) | + XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_ERROR_MASK; /* Only set interrupt delay timer if not generating an interrupt on * the first RX packet. Otherwise leave at 0 to disable delay interrupt. */ if (lp->coalesce_count_rx > 1) - rx_cr |= (XAXIDMA_DFT_RX_WAITBOUND << XAXIDMA_DELAY_SHIFT) | - XAXIDMA_IRQ_DELAY_MASK; - axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, rx_cr); + lp->rx_dma_cr |= (XAXIDMA_DFT_RX_WAITBOUND << XAXIDMA_DELAY_SHIFT) | + XAXIDMA_IRQ_DELAY_MASK; + axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, lp->rx_dma_cr); /* Start updating the Tx channel control register */ tx_cr = (lp->coalesce_count_tx << XAXIDMA_COALESCE_SHIFT) | @@ -260,8 +260,8 @@ static void axienet_dma_start(struct axienet_local *lp) * halted state. This will make the Rx side ready for reception. */ axienet_dma_out_addr(lp, XAXIDMA_RX_CDESC_OFFSET, lp->rx_bd_p); - rx_cr |= XAXIDMA_CR_RUNSTOP_MASK; - axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, rx_cr); + lp->rx_dma_cr |= XAXIDMA_CR_RUNSTOP_MASK; + axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, lp->rx_dma_cr); axienet_dma_out_addr(lp, XAXIDMA_RX_TDESC_OFFSET, lp->rx_bd_p + (sizeof(*lp->rx_bd_v) * (lp->rx_bd_num - 1))); @@ -875,28 +875,26 @@ axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev) } /** - * axienet_recv - Is called from Axi DMA Rx Isr to complete the received - * BD processing. - * @ndev: Pointer to net_device structure. + * axienet_poll - Triggered by RX ISR to complete the received BD processing. + * @napi: Pointer to NAPI structure. + * @budget: Max number of packets to process. * - * This function is invoked from the Axi DMA Rx isr to process the Rx BDs. It - * does minimal processing and invokes "netif_rx" to complete further - * processing. + * Return: Number of RX packets processed. */ -static void axienet_recv(struct net_device *ndev) +static int axienet_poll(struct napi_struct *napi, int budget) { u32 length; u32 csumstatus; u32 size = 0; - u32 packets = 0; + int packets = 0; dma_addr_t tail_p = 0; - struct axienet_local *lp = netdev_priv(ndev); - struct sk_buff *skb, *new_skb; struct axidma_bd *cur_p; + struct sk_buff *skb, *new_skb; + struct axienet_local *lp = container_of(napi, struct axienet_local, napi); cur_p = &lp->rx_bd_v[lp->rx_bd_ci]; - while ((cur_p->status & XAXIDMA_BD_STS_COMPLETE_MASK)) { + while (packets < budget && (cur_p->status & XAXIDMA_BD_STS_COMPLETE_MASK)) { dma_addr_t phys; /* Ensure we see complete descriptor update */ @@ -918,7 +916,7 @@ static void axienet_recv(struct net_device *ndev) DMA_FROM_DEVICE); skb_put(skb, length); - skb->protocol = eth_type_trans(skb, ndev); + skb->protocol = eth_type_trans(skb, lp->ndev); /*skb_checksum_none_assert(skb);*/ skb->ip_summed = CHECKSUM_NONE; @@ -937,13 +935,13 @@ static void axienet_recv(struct net_device *ndev) skb->ip_summed = CHECKSUM_COMPLETE; } - netif_rx(skb); + napi_gro_receive(napi, skb); size += length; packets++; } - new_skb = netdev_alloc_skb_ip_align(ndev, lp->max_frm_size); + new_skb = netdev_alloc_skb_ip_align(lp->ndev, lp->max_frm_size); if (!new_skb) break; @@ -952,7 +950,7 @@ static void axienet_recv(struct net_device *ndev) DMA_FROM_DEVICE); if (unlikely(dma_mapping_error(lp->dev, phys))) { if (net_ratelimit()) - netdev_err(ndev, "RX DMA mapping error\n"); + netdev_err(lp->ndev, "RX DMA mapping error\n"); dev_kfree_skb(new_skb); break; } @@ -972,11 +970,20 @@ static void axienet_recv(struct net_device *ndev) cur_p = &lp->rx_bd_v[lp->rx_bd_ci]; } - ndev->stats.rx_packets += packets; - ndev->stats.rx_bytes += size; + lp->ndev->stats.rx_packets += packets; + lp->ndev->stats.rx_bytes += size; if (tail_p) axienet_dma_out_addr(lp, XAXIDMA_RX_TDESC_OFFSET, tail_p); + + if (packets < budget && napi_complete_done(napi, packets)) { + /* Re-enable RX completion interrupts. This should + * cause an immediate interrupt if any RX packets are + * already pending. + */ + axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, lp->rx_dma_cr); + } + return packets; } /** @@ -1022,7 +1029,7 @@ static irqreturn_t axienet_tx_irq(int irq, void *_ndev) * * Return: IRQ_HANDLED if device generated a RX interrupt, IRQ_NONE otherwise. * - * This is the Axi DMA Rx Isr. It invokes "axienet_recv" to complete the BD + * This is the Axi DMA Rx Isr. It invokes NAPI polling to complete the RX BD * processing. */ static irqreturn_t axienet_rx_irq(int irq, void *_ndev) @@ -1045,7 +1052,15 @@ static irqreturn_t axienet_rx_irq(int irq, void *_ndev) (lp->rx_bd_v[lp->rx_bd_ci]).phys); schedule_work(&lp->dma_err_task); } else { - axienet_recv(lp->ndev); + /* Disable further RX completion interrupts and schedule + * NAPI receive. + */ + u32 cr = lp->rx_dma_cr; + + cr &= ~(XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_DELAY_MASK); + axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr); + + napi_schedule(&lp->napi); } return IRQ_HANDLED; @@ -1121,6 +1136,8 @@ static int axienet_open(struct net_device *ndev) /* Enable worker thread for Axi DMA error handling */ INIT_WORK(&lp->dma_err_task, axienet_dma_err_handler); + napi_enable(&lp->napi); + /* Enable interrupts for Axi DMA Tx */ ret = request_irq(lp->tx_irq, axienet_tx_irq, IRQF_SHARED, ndev->name, ndev); @@ -1146,6 +1163,7 @@ static int axienet_open(struct net_device *ndev) err_rx_irq: free_irq(lp->tx_irq, ndev); err_tx_irq: + napi_disable(&lp->napi); phylink_stop(lp->phylink); phylink_disconnect_phy(lp->phylink); cancel_work_sync(&lp->dma_err_task); @@ -1169,6 +1187,8 @@ static int axienet_stop(struct net_device *ndev) dev_dbg(&ndev->dev, "axienet_close()\n"); + napi_disable(&lp->napi); + phylink_stop(lp->phylink); phylink_disconnect_phy(lp->phylink); @@ -1704,6 +1724,8 @@ static void axienet_dma_err_handler(struct work_struct *work) dma_err_task); struct net_device *ndev = lp->ndev; + napi_disable(&lp->napi); + axienet_setoptions(ndev, lp->options & ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN)); @@ -1768,6 +1790,7 @@ static void axienet_dma_err_handler(struct work_struct *work) axienet_set_mac_address(ndev, NULL); axienet_set_multicast_list(ndev); axienet_setoptions(ndev, lp->options); + napi_enable(&lp->napi); } /** @@ -1816,6 +1839,8 @@ static int axienet_probe(struct platform_device *pdev) lp->rx_bd_num = RX_BD_NUM_DEFAULT; lp->tx_bd_num = TX_BD_NUM_DEFAULT; + netif_napi_add(ndev, &lp->napi, axienet_poll, NAPI_POLL_WEIGHT); + lp->axi_clk = devm_clk_get_optional(&pdev->dev, "s_axi_lite_clk"); if (!lp->axi_clk) { /* For backward compatibility, if named AXI clock is not present, From patchwork Sat Mar 5 02:24:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12770233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 07871C433EF for ; Sat, 5 Mar 2022 02:28:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hattnmcgTSZr1wgXe0xhhu5qD9kzkj11PmWpp3Fmh4w=; b=Wed/XwRIsCiKr/ d2ryVl+zWRZSyf8Go5zi0itBUZUUeFfHQEhmKRVPMZ9RYtxts8Np7mOw7UOfEcaQJ5SwJDVa7PjYD EFf/LRH4/kZVnG9cD3JTwWuV94DSDGclQxZa0U79Fy4WIsOvCbuh0aQz3B5b0qa6kySSpOBj4COcM e3Qw3k1x0+/qHriGpdniBP3goyHazN3h57kxYrFEFSbbFhYU7nLS8mFMZTheV8qXmM7vhqJEnVpmV EVIOYs5TgYi9vfNFNjTiMiznWEym/5AaLNVKvXC/IMdtasOGhJk2usqEb6TBifxpJa2Ra3S9TZOTO WVFfWkg7n0uMTuTC5ixQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQK8A-00Cb2X-9g; Sat, 05 Mar 2022 02:26:50 +0000 Received: from mx0d-0054df01.pphosted.com ([67.231.150.19]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQK6h-00CaVN-48 for linux-arm-kernel@lists.infradead.org; Sat, 05 Mar 2022 02:25:20 +0000 Received: from pps.filterd (m0209000.ppops.net [127.0.0.1]) by mx0c-0054df01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 22526BSB005431; Fri, 4 Mar 2022 21:25:04 -0500 Received: from can01-qb1-obe.outbound.protection.outlook.com (mail-qb1can01lp2052.outbound.protection.outlook.com [104.47.60.52]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3ek4hy8qh5-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Mar 2022 21:25:03 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CeOJoBMSR5uV01RQSOrmvY9Cq7q+ZiNrz18n0MqvMgZhstOUlDwVXJwZZxVSrLmGa5jvYSYDCjyg5ABNIihhniwue17Sb3yyxJ3rcbYr5bQFjTW7HeEoQFBiINUo5Hd6m6+WBGMrLlY43U1i6+eApfrQKeuQDVRTGfoK4i/71Q83nRTBP/kYnHU7zWOwqVCg8q6qkjHT2iRiNWSjqz6Dtos7ItHr/aRnl61pwM2GCLGdVZ9NxyYhOuB0htRkri+tMTrcRuPxD+pn/euvbcH9v7fCrISxiot5leAZO6Vd3Iq/H+yiHcxAPLsUX8aiAkIOyn1i1rphwKOd8Wi0NfjmZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yUCq2UikCIWxBI73BK0upvu2ClQMceTulwcjfUe1u8o=; b=eNB7Ryt+Jt2e0j684IDfKW9bq0JD9wux6d3ZENTNV6CzngloyTAlpMpfb5iVZP/ZbGAweCLOq3zrLydczF9Y1zfVhPM0wvgbGr4msUywLo7gbXn9N3pDNuCsWsTSxiwstjgrDgdGJGPqOMGmHEPgoUtyFPTqtk2EUK6+PKB/IszRsEOz1G+2ZnweWsK5p0Bzl3L9jcyzel4rfCDqbDBHQZUnHTNdKACUgmVaX84xWBdUk5X+9f2ugZNpRYx2MUqASLBmSPl7E1W+O04g/61loUpc9ZsWcREBJ3YLSM31akN4MVwxTDNHV25B80c1GiYJNDAD0t1ouEoN0B9R7qpteg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=calian.com; dmarc=pass action=none header.from=calian.com; dkim=pass header.d=calian.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=calian.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yUCq2UikCIWxBI73BK0upvu2ClQMceTulwcjfUe1u8o=; b=l9P56fJEZVZL1lEj/LVhgyPXpJg/gHJPGtJpuWcBhe2kHzLGx6/ErvQVWvA7LHF8kE9hOQF9OAOoDmFO6v6JRmxMwDYwMP8KNTN2GVR+YjezBG3l2aMEYeCInY6VtyA2ueOcWqZtyuhnnLOD3qD+bRDk4KAoFzE5GVGWWFnOqoQ= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (10.167.1.243) by YTBPR01MB3184.CANPRD01.PROD.OUTLOOK.COM (10.255.47.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Sat, 5 Mar 2022 02:25:02 +0000 Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::e8a8:1158:905f:8230]) by YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::e8a8:1158:905f:8230%7]) with mapi id 15.20.5038.017; Sat, 5 Mar 2022 02:25:02 +0000 From: Robert Hancock To: netdev@vger.kernel.org Cc: radhey.shyam.pandey@xilinx.com, davem@davemloft.net, kuba@kernel.org, michal.simek@xilinx.com, linux@armlinux.org.uk, daniel@iogearbox.net, linux-arm-kernel@lists.infradead.org, Robert Hancock Subject: [PATCH net-next v3 6/7] net: axienet: reduce default RX interrupt threshold to 1 Date: Fri, 4 Mar 2022 20:24:42 -0600 Message-Id: <20220305022443.2708763-7-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220305022443.2708763-1-robert.hancock@calian.com> References: <20220305022443.2708763-1-robert.hancock@calian.com> X-ClientProxiedBy: MW4PR03CA0304.namprd03.prod.outlook.com (2603:10b6:303:dd::9) To YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a0074cad-fa35-48d3-6fa9-08d9fe4f5a9c X-MS-TrafficTypeDiagnostic: YTBPR01MB3184:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QtcUsrKpqv8yeVO96ZLHcJZK1F5pzZCQ0o2FzbOOJMZQGZQt1kvIwYavhTA1kgRrxUPGcnlu5YhOFIJwJPPgQeos7AiKDKO/0Umq1CbGkdaxROXuAXC7FiGv64AC5eTYT2j7+nBoqtQ/+E47FwHyT1jGu83AFb9weQjmEXf1WPr9lZJ3pe3IQCn8ykFJiemppZ7vhLKnXf2aWHtMkj9FaVdGUmMehuBINtMzty33/MyBW22jVW4biC9KYZvuqFkPrIMORMqjYxG+wr3YY5f/wKI9OtYGTjicZpjqDTi6yfYcKfd1rVrZo4a1jSSP7j1tzbFe/d6bH8CkiRECos0RhZbYn6TeqYY/hpop9ARpj7Huhv5us2t/vWTsLOOItqx0LAJ4XVdTjtj8ld+Mp5f3VRS0Fsi/9aVo2/pl2hUfIpcn02IPN6uu1U/zYnlUwKFTL4bb32wFb3Ms9nCCVFzLrkuU7hYiREeyti4vq4z9P2+UEneMZ5bkwTN1sAerfr6pXA9Ke6/tZXcweXu3L0k+Th+5smyZuCyT/h4N/xU8MTkFbcC0LLnCirBUlTvvgQlyJ4SOcxFWNMmIfMCPobK5BAYRTMoJ8Jn/maZxVIj9Dbec4wbiO/vjlV58h50iRVUo8kuw5rJZjFw2tKZS6cMRXItVcPFOUyU95kxjLgn5H7dF7jJxMaGK5ZIovk+xY0MnvJJw+H9jNW/3IAyyfBOQng== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(36756003)(2906002)(107886003)(5660300002)(26005)(186003)(83380400001)(6916009)(4326008)(2616005)(1076003)(8936002)(44832011)(6486002)(38350700002)(38100700002)(508600001)(86362001)(316002)(6666004)(52116002)(8676002)(66556008)(66476007)(66946007)(6506007)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QI+WwfJh4JqbufL4KrnQLgHOVjLjqQ/0YDS5sF2ds0IaQYRVeEWR1l6JiHKzp/iQfU2TWX8neoOL70sY/IVS7PXIHTA2WnR8wEnHWUakpAwhRKy6+rG3rSgnkwNteqcHMRjTOOqfd/VPS3063HPC4cjrTVMPlKLk05mxXuRevYxaMT1cPcGUjQ0s66E9ZnfqgsAmcwyXNqTcEdCkMPvUYItCg1m7CUqJ61pxxilaOayKx2LQ+eYh4kbBrkMBGxIAi5aQuu0vDOhTHtgd7xzD4m/+r0Rv276Fr2feEJMyIS3yithm5dJ1g5hR1J8ZsSTJb/tnqtug2vBg9EMLSW+4CM4w/B6rPUtBl4kFvaabij0X7Zxon82PrD5g8u5Kj/qCnRzkpZA+OVABJmAY1bl0vMlcCYe908FooL1rt74ZieyeAu/gwT98HcOBRFrkHYli2tdVjwzT9mM2+5TCRWaCWc/p2bwBrKpOJI3AF56c9uwAjNVikPxG7s2qwQebSFLlWQcBwERfJcYmRHwKelv1MyKlTJcQO1TDE0Lry6fqkl17KLnxn+uVIB33LABzGraTbAKuHTPUgo3PeMtFB9+bcBpdo0S5wW+6s+41Cp/fciHRSuHJDY656NpGk1Q7/iz5RmeTALeKJSTqdFohV0YhUREIqbJ51njeRhnCGjHH8eN2+YNZUl9byAUomih8cR03bJwxrWWEWVWk+L2EiRd+XiA+gDaebZjTDROdhF5ZXlcWLT0Wg1ZeKP/GCBkBAlvc+zvhqrwu44hYsYiHkGIkivkAo64Q7ijlc6dR83NoEUlXrXFHATAIiPCvggHs1MQ970iJfj3+6VV1dswEabU/0ag6ceUtlfguHb0ssMzIJuE22NGL8Q6W72/vFbn5szbTfp8EAKvigAy7ro4CH3NaUcVHNt1+w1uRhNTDGO8Hs2MLX1Fw3zBiIBGjcknxeAN8x179oWXxYKhINmN5q88eulvC63t3YhZVwl9S6jBZfLNf3Qu+9doFbGFPJYANfnV7nlW+ViNLTddqTz0HzqjETCyp2yzvQVajCdI5AQmWbivZtaw+7u3cT/v7RZCVcBNGqwLwgCdtwoDSqAc5gkUz9C6+ixJWwb+Rvg0dpqGBNi8AFfB5sScT25udxEThoXzFW+fq7fMGGqWCao3UkTnmfKV0ST2xwS1YDBChVGfcGSrl4CdoIfMsOI56Ru3xuUSzFvrfEkw6uZIWzewakLIEqF/lVO/6DcMPefIprgQX0Cd04RGV6mFd/HZwe9VYvizQyH1vuEh6Wn2wtG4nj2YBUQFX2Xo+eRO9fEihqXqNpacZOOPWM7TKogEpsZ17eJ8spqDuwPTgbTjPiMpN/Ox3Yo61tQNR056coc4dVmyWbtF/tDSilV4ggra8cXbzXB1bVqhQPFtEvrBD4Yrt5rFVW46Lru4ZsnV+35VTy4o7J+fsrrT3Zgt/yr/xNTIZEXq+nXe9DZ+2dGkbWajlWdg5FosNb90KGGbRQjvUk/xXMMuXkRZHATmAjfOd2Y+SL5OjRpwX9v99FdwsDDfde4HhdjFjjvUftpYF12rfl7+K/0Krkaah3N09NAi2pxvjpzFWIWkWEbHY5HscVJHKmgPwzqRjH+SEgUVyI1BBiVXgwqhyBPiSdvniImsXZFexnkqKyt1Lj9i0oJZHljS5j7CZUftvVZbguX4H0acKyAeGTYA= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0074cad-fa35-48d3-6fa9-08d9fe4f5a9c X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2022 02:25:02.7417 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 23b57807-562f-49ad-92c4-3bb0f07a1fdf X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9Lgda7qE1nixrZ2LAobt2kgDh009cNWRlvWTOQLyR335VsbI6pEyndbemjiIAEzCMxDHYM5QpQNGPaI1VUjXUFgLkmEmx+ZCsmlgsRAwj14= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YTBPR01MB3184 X-Proofpoint-ORIG-GUID: WYbwRX_PFtlcwGcJ3fqn0rU3sYgDe3rG X-Proofpoint-GUID: WYbwRX_PFtlcwGcJ3fqn0rU3sYgDe3rG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-04_09,2022-03-04_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=4 lowpriorityscore=0 bulkscore=0 mlxscore=4 malwarescore=0 impostorscore=0 clxscore=1015 priorityscore=1501 adultscore=0 mlxlogscore=141 phishscore=0 suspectscore=0 spamscore=4 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203050007 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220304_182519_316141_4265F26E X-CRM114-Status: GOOD ( 10.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Now that NAPI has been implemented, the hardware interrupt mitigation mechanism is not needed to avoid excessive interrupt load in most cases. Reduce the default RX interrupt threshold to 1 to reduce introduced latency. This can be increased with ethtool if desired if some applications still want to reduce interrupts. Signed-off-by: Robert Hancock --- drivers/net/ethernet/xilinx/xilinx_axienet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/ethernet/xilinx/xilinx_axienet.h index c771827587b3..6f0f13b4fb1a 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet.h +++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h @@ -122,7 +122,7 @@ /* Default TX/RX Threshold and waitbound values for SGDMA mode */ #define XAXIDMA_DFT_TX_THRESHOLD 24 #define XAXIDMA_DFT_TX_WAITBOUND 254 -#define XAXIDMA_DFT_RX_THRESHOLD 24 +#define XAXIDMA_DFT_RX_THRESHOLD 1 #define XAXIDMA_DFT_RX_WAITBOUND 254 #define XAXIDMA_BD_CTRL_TXSOF_MASK 0x08000000 /* First tx packet */ From patchwork Sat Mar 5 02:24:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12770235 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 13B17C433EF for ; Sat, 5 Mar 2022 02:29:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZQP4cZWwaKxsrqZbjwHVBIvCmuPyR+Ky79qOr6Gj8wc=; b=nj+JXBfkzC+coT ar7lZo1j5eCqyzXxX0mFA7xTTTtXZ8evRkYhswGYCPLDgpSbDiG9uCKGj5mmMr+HRpq8/tUx6JQrK UkdjCuS+9izVsJTLhblV5+xbdBzNVv+LtQajtNVaTduusO6qlEw8RldKtKtgblcfGXyYplyBMds6B U/g8gldE6WAUaj2LAe5RQ3WLvEdck+uwJDvz3aNSEKAFrhdu/JSlk44N+I1M6YQTWvu0JUNeoxf7k pzcQqnoBRaNiwljkZrMuaYQ1mv/IEzuHXzaPF4hUdcKgT9TMD5m1n2/aT2URI1H1QUb7J8ZbIi3CN M720ujN+JHfhzCgZiSyg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQK9N-00CbYQ-MV; Sat, 05 Mar 2022 02:28:06 +0000 Received: from mx0d-0054df01.pphosted.com ([67.231.150.19]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQK6j-00CaWM-Lu for linux-arm-kernel@lists.infradead.org; Sat, 05 Mar 2022 02:25:23 +0000 Received: from pps.filterd (m0209000.ppops.net [127.0.0.1]) by mx0c-0054df01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 2251xTip028466; Fri, 4 Mar 2022 21:25:05 -0500 Received: from can01-qb1-obe.outbound.protection.outlook.com (mail-qb1can01lp2059.outbound.protection.outlook.com [104.47.60.59]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3ek4hy8qh6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Mar 2022 21:25:05 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YXB1x58yCALBWC2wLOCoOOCCo31OJzBFKTjdrhj5h80vkEPi4ndA2NtIUKtnP5aSviOuIEVqmXTYAb1D6q8261ivSgnlXMmBCejFNzU9ejuGFMcACCf7LgsWWyBF2jlxbxFRSCAhsdYao3JNqRt/3UsgIC/orT30wPUDwEr0HOCvkrbDppAKSCH0Ilx29qNdortyAjfN7dw7Vuhwf8GCJ1zhBPTvsWiu13GUdU8exqmUpIDiJcjRsQhWAWZj6I3cHMw8/zuc47i+zs7dOdxtKMTKGCmEZQfNNsHwy3raWhI4uTsdGGiTB9pEtg5/ZqgiGI2AP+xSm6R8Iwz6zZj3mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=i/mhy89Aun6T16vM9L2JncCHXxVTmMnVX8HrwQjnRjg=; b=TQmOGr0umf4sEDHnq8xjGsXa3qmz1hxLrN64WWZVUOMc0NlpyX4tBXbhxsE7cvUedK+iHBOwjqaNJK3v2q3AU07yPixEETbJ6HbQmmVrqT+qGQgzQdhg6+5JdpKXUsDxhYgpublRGh0xjrgG28X6HjnLWRiZt1atI/3A8MvCDEpxhe8xN9c5VumWOPDsEDOf2DP2l7SUufMfxkLm2LurcxwNBnaUQEH6MbdzwNKmFP/7BNbBRITIx4DN0jeDZTWRF++iJh2o4J3wkOILMpqMj0Mz8FtC4IxHyJOKOF2Kpnr32DaYZ7AebFiuYma+kqagrfM3lp8/UzRnLxvlmh8F1Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=calian.com; dmarc=pass action=none header.from=calian.com; dkim=pass header.d=calian.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=calian.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=i/mhy89Aun6T16vM9L2JncCHXxVTmMnVX8HrwQjnRjg=; b=0tLRmJBJgO+TIS6iQNijf6QfCN+f6K67ynmZZieXDUEPP36BnmaS0kqaT6aP124XxOaiwdRzOBTwF70QZGWNdarNeLxk/lLCpy86zslDb4JDjSyGUeghuST8SBEAeuHWsRirSatIHfl7Oeen058pigonNHuvLj4qODSsd+JztbQ= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (10.167.1.243) by YTBPR01MB3184.CANPRD01.PROD.OUTLOOK.COM (10.255.47.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Sat, 5 Mar 2022 02:25:04 +0000 Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::e8a8:1158:905f:8230]) by YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::e8a8:1158:905f:8230%7]) with mapi id 15.20.5038.017; Sat, 5 Mar 2022 02:25:04 +0000 From: Robert Hancock To: netdev@vger.kernel.org Cc: radhey.shyam.pandey@xilinx.com, davem@davemloft.net, kuba@kernel.org, michal.simek@xilinx.com, linux@armlinux.org.uk, daniel@iogearbox.net, linux-arm-kernel@lists.infradead.org, Robert Hancock Subject: [PATCH net-next v3 7/7] net: axienet: add coalesce timer ethtool configuration Date: Fri, 4 Mar 2022 20:24:43 -0600 Message-Id: <20220305022443.2708763-8-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220305022443.2708763-1-robert.hancock@calian.com> References: <20220305022443.2708763-1-robert.hancock@calian.com> X-ClientProxiedBy: MW4PR03CA0304.namprd03.prod.outlook.com (2603:10b6:303:dd::9) To YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 57b5ca24-c60b-453b-e639-08d9fe4f5b66 X-MS-TrafficTypeDiagnostic: YTBPR01MB3184:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TMw2ay8apSkgS0ojARakTDD9lVjUijsIwdUHLk1KSdi8D3Gab+9oUmxyr7vmZLiXviYklbMm1aTlHPFd7+K3SKMtxFbV3fNhDFPBJw62ElWD2VeCJyxXmrtU5VknjiDiOzR7mC4eY9ePDGVGH8a5/Ylhl/26o1qPK6LqpIkbaG/fJpB2dfRoC64bP+rtSyTmiR1FEIr9sc110BS8VXzjH1SVdNj1c/OM5fw/eoSt3NHAyWEqPLrZi57AfKwTjelOdFOy6zl0/xuIQthB5w+BdXHPojxS/mWpBBfYELZJ1yMmSGrYQwnbKQYUcK1ckjJIXIYDxsa5vkWIxD3NHXZjhhdrOe8CMRbtW/7dkY9UfM5zKMsFMfxlwXCYfo/XiZZn074cFtzG/hSC+NPwGmRUM18edgyqXjzZPOP1PebUYJElv7Ou6dz1k8jcmxqf+aLDQbrGo+DwbZ1VfoH2NSM0rxarZZbqHRCKMvblCxexNRCHWvhpkq+Ka6ttD58EtwWHfTzZC+ABcgAKDBfbkV4cgL2Zfc6FKKyrx1jDZh2LFAYL/i5045e1UzeJ1nqSY+613fjiw7wdqBrJekvofI/7wWU5u9xFuvu1ya15iW8EE9KOS0VWNe8IwBGsADeYXV+HhQrjul5mnPqOuFLoDlmyIUs7+E5IN6iqg7FkAvQl0KSJbsch1glD68TZW3OyHI8Xu35Q9W/aypROxBBMI3B2iA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(36756003)(2906002)(107886003)(5660300002)(26005)(186003)(83380400001)(6916009)(4326008)(2616005)(1076003)(8936002)(44832011)(6486002)(38350700002)(38100700002)(508600001)(86362001)(316002)(6666004)(52116002)(8676002)(66556008)(66476007)(66946007)(6506007)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 54Q1sjsOGEDW+eUHSE4ios7bJfOUGeiCXjlrLIyy6fjjntc44mWKyzQ0ZqiAcm09fEOcpPf2Hf/M+njId75cSLlt7qrrN9eFJDvbwdFtl1vCqGO3opMPSoE1O89718BHBPOTuOdaWOeIWi28CzKZNarN7eNEYWSrMCZB2cSan+btw6GmpehyfHgXygJtzDg2qkKO+IVN71h0kLuWoaT2fA86SJCZOs+jfhkzweUzSjMWMccwdQ9xobFRT2InKuyjXbpNLk1S9d/rnaauTycuobcHndRL/Ti1N7tRz0q3RTvkPpbKCgeP2N40N+C3ULB8Ll/sFQu6f+zzx5eQrc8bAeLufT5nJa+fQNhalWZJw31PApmXhLaRix2xN4b9G17ocZUBzlm5OefkrVYGD1g39pjEGpfBg84+h7IIyjmak/MSbl3s9ebHbyirnL3nakqhOKj/+1SfukDUUqOkIP+9hwSc2x6SgeuF6p3F0Y1lXwj5/UW2owfEGgJgW8jpwXE6JqZTwg05SFysHyxvehMbKJDvzrRX2I3sMw+wdGSRZ6pT10afeCI1Q2OmMAXspR6H3hhpL3c8njKV2mwXjx0cucQkhA9Wi+qGryKqyG6N/DCUuyBfBM42+0AnyhYEwRPIbc6V6DW7MyNvN3BxhXVAa/jFREnyVf8/TWNqxML7ChK24hHwXoDAY0z5m+/pTyNG6ISvzw68kU53ZEAkdOmNoMC0pHHl+nrPZGFnEMxcMQv9V3NjqLnrjjQtlpqB4YUqj10GmFMLFZnbKAsKQB1ZcbBCjuYNjZVTsWS3mGGIbSeEKJE2rZaTb3AqUO88ZxJV4D4EosKSPZP7fwzcgTU/S8Vaqg/uZfbQ/XdUatT0WrzNMxAZcS/IL2cCZRZVjAW5oEyrvhrZQJSPvNZMZiSkjQT5BobWACQum6CyjuL486a90hU+Dhv9vEW9oINhlRqgHUD4EZSHIfu+babQyaIr/sH4zEzzFFgte+o8CDL9CySFTrorQQ2kpvggxm1DShRSVSKQ4hbnFPmFyOrm2CX9BFlsj7WNCung/0TSPh78fvAa27qBjOv3bU5tQbhgYRR5PcWmgzK18C1HCrMiDAS1sN1uPVkxx7ILcyBPiaqksL2sLGg4z7/JMPc/8DghOG7m8MhNULYfPOoYRfGXgnFVEkNe5YEiQJqfvd5w1aNrhqyxQ9hTlphsDFM5vssmQmNDpBHBC1JC9oHpHCZIfKa/Ks47CRSA9ubHOUX96psDayWBZnDKlkf3Hgg837dD/SVVInNDLclomTlcPJryQt3uZAfvrZvG9CspCT4yMPs5SdvNW+vkY4nntLfdGUyH3gd4MIVbb6VOmNjC3Dy73cTe5ivI1mvArlZWfAwSRzGzXTvHHOU/CFNUh9aoSbETJrfqmdox1q67UlYXLh8jreKiLy6xLJMMiA/4EGRvZMdFdRFLxNvDOeOxwZrg6EtqDpWACXDKiI/atqrCKyUMbBkOMpKlW+9KjmlE1GuLZqmT74ylimnTAZPKbbuPZSUFlw/unFnV60XlkZ/woIV/4rjoiaVQOYN13aBqP2XoTYMROIXEki1D9kT0WV/LyklVvJNCJwaeWQ35bh7ZVlXXqtY/6gp+K8eB2brlCAFRE/8haMmTcpdzhEYxlVUe35Geww4rPQiukLkH3LCDvfZxegZtvToyAZZIlWoCNSya7MqrLVE= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57b5ca24-c60b-453b-e639-08d9fe4f5b66 X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2022 02:25:04.0083 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 23b57807-562f-49ad-92c4-3bb0f07a1fdf X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: b2ajNBqQOtKlvPwd2uqmQw1G3DaUN//jltaaYGWc11Mk6VCufeMj+V54eNZEYTjE7yOYrPOPKvQTN/exjmONGJ4FQ/pXoZg/7anB1wuPXpc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YTBPR01MB3184 X-Proofpoint-ORIG-GUID: 0V6nM7LzEIpG6PvTuCKiPPeVf5llldfV X-Proofpoint-GUID: 0V6nM7LzEIpG6PvTuCKiPPeVf5llldfV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-04_09,2022-03-04_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 mlxscore=0 malwarescore=0 impostorscore=0 clxscore=1015 priorityscore=1501 adultscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203050007 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220304_182521_895556_FA7FC7C0 X-CRM114-Status: GOOD ( 19.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add the ability to configure the RX/TX coalesce timer with ethtool. Change default setting to scale with the clock rate rather than being a fixed number of clock cycles. Signed-off-by: Robert Hancock --- drivers/net/ethernet/xilinx/xilinx_axienet.h | 10 ++-- .../net/ethernet/xilinx/xilinx_axienet_main.c | 51 +++++++++++++++---- 2 files changed, 47 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/ethernet/xilinx/xilinx_axienet.h index 6f0f13b4fb1a..0f9c88dd1a4a 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet.h +++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h @@ -119,11 +119,11 @@ #define XAXIDMA_IRQ_ERROR_MASK 0x00004000 /* Error interrupt */ #define XAXIDMA_IRQ_ALL_MASK 0x00007000 /* All interrupts */ -/* Default TX/RX Threshold and waitbound values for SGDMA mode */ +/* Default TX/RX Threshold and delay timer values for SGDMA mode */ #define XAXIDMA_DFT_TX_THRESHOLD 24 -#define XAXIDMA_DFT_TX_WAITBOUND 254 +#define XAXIDMA_DFT_TX_USEC 50 #define XAXIDMA_DFT_RX_THRESHOLD 1 -#define XAXIDMA_DFT_RX_WAITBOUND 254 +#define XAXIDMA_DFT_RX_USEC 50 #define XAXIDMA_BD_CTRL_TXSOF_MASK 0x08000000 /* First tx packet */ #define XAXIDMA_BD_CTRL_TXEOF_MASK 0x04000000 /* Last tx packet */ @@ -425,7 +425,9 @@ struct axidma_bd { * @csum_offload_on_tx_path: Stores the checksum selection on TX side. * @csum_offload_on_rx_path: Stores the checksum selection on RX side. * @coalesce_count_rx: Store the irq coalesce on RX side. + * @coalesce_usec_rx: IRQ coalesce delay for RX * @coalesce_count_tx: Store the irq coalesce on TX side. + * @coalesce_usec_tx: IRQ coalesce delay for TX */ struct axienet_local { struct net_device *ndev; @@ -482,7 +484,9 @@ struct axienet_local { int csum_offload_on_rx_path; u32 coalesce_count_rx; + u32 coalesce_usec_rx; u32 coalesce_count_tx; + u32 coalesce_usec_tx; }; /** diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 860ff0447f71..a51a8228e1b7 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include @@ -226,6 +226,28 @@ static void axienet_dma_bd_release(struct net_device *ndev) lp->rx_bd_p); } +/** + * axienet_usec_to_timer - Calculate IRQ delay timer value + * @lp: Pointer to the axienet_local structure + * @coalesce_usec: Microseconds to convert into timer value + */ +static u32 axienet_usec_to_timer(struct axienet_local *lp, u32 coalesce_usec) +{ + u32 result; + u64 clk_rate = 125000000; /* arbitrary guess if no clock rate set */ + + if (lp->axi_clk) + clk_rate = clk_get_rate(lp->axi_clk); + + /* 1 Timeout Interval = 125 * (clock period of SG clock) */ + result = DIV64_U64_ROUND_CLOSEST((u64)coalesce_usec * clk_rate, + (u64)125000000); + if (result > 255) + result = 255; + + return result; +} + /** * axienet_dma_start - Set up DMA registers and start DMA operation * @lp: Pointer to the axienet_local structure @@ -241,7 +263,8 @@ static void axienet_dma_start(struct axienet_local *lp) * the first RX packet. Otherwise leave at 0 to disable delay interrupt. */ if (lp->coalesce_count_rx > 1) - lp->rx_dma_cr |= (XAXIDMA_DFT_RX_WAITBOUND << XAXIDMA_DELAY_SHIFT) | + lp->rx_dma_cr |= (axienet_usec_to_timer(lp, lp->coalesce_usec_rx) + << XAXIDMA_DELAY_SHIFT) | XAXIDMA_IRQ_DELAY_MASK; axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, lp->rx_dma_cr); @@ -252,7 +275,8 @@ static void axienet_dma_start(struct axienet_local *lp) * the first TX packet. Otherwise leave at 0 to disable delay interrupt. */ if (lp->coalesce_count_tx > 1) - tx_cr |= (XAXIDMA_DFT_TX_WAITBOUND << XAXIDMA_DELAY_SHIFT) | + tx_cr |= (axienet_usec_to_timer(lp, lp->coalesce_usec_tx) + << XAXIDMA_DELAY_SHIFT) | XAXIDMA_IRQ_DELAY_MASK; axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, tx_cr); @@ -1488,14 +1512,12 @@ axienet_ethtools_get_coalesce(struct net_device *ndev, struct kernel_ethtool_coalesce *kernel_coal, struct netlink_ext_ack *extack) { - u32 regval = 0; struct axienet_local *lp = netdev_priv(ndev); - regval = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET); - ecoalesce->rx_max_coalesced_frames = (regval & XAXIDMA_COALESCE_MASK) - >> XAXIDMA_COALESCE_SHIFT; - regval = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET); - ecoalesce->tx_max_coalesced_frames = (regval & XAXIDMA_COALESCE_MASK) - >> XAXIDMA_COALESCE_SHIFT; + + ecoalesce->rx_max_coalesced_frames = lp->coalesce_count_rx; + ecoalesce->rx_coalesce_usecs = lp->coalesce_usec_rx; + ecoalesce->tx_max_coalesced_frames = lp->coalesce_count_tx; + ecoalesce->tx_coalesce_usecs = lp->coalesce_usec_tx; return 0; } @@ -1528,8 +1550,12 @@ axienet_ethtools_set_coalesce(struct net_device *ndev, if (ecoalesce->rx_max_coalesced_frames) lp->coalesce_count_rx = ecoalesce->rx_max_coalesced_frames; + if (ecoalesce->rx_coalesce_usecs) + lp->coalesce_usec_rx = ecoalesce->rx_coalesce_usecs; if (ecoalesce->tx_max_coalesced_frames) lp->coalesce_count_tx = ecoalesce->tx_max_coalesced_frames; + if (ecoalesce->tx_coalesce_usecs) + lp->coalesce_usec_tx = ecoalesce->tx_coalesce_usecs; return 0; } @@ -1560,7 +1586,8 @@ static int axienet_ethtools_nway_reset(struct net_device *dev) } static const struct ethtool_ops axienet_ethtool_ops = { - .supported_coalesce_params = ETHTOOL_COALESCE_MAX_FRAMES, + .supported_coalesce_params = ETHTOOL_COALESCE_MAX_FRAMES | + ETHTOOL_COALESCE_USECS, .get_drvinfo = axienet_ethtools_get_drvinfo, .get_regs_len = axienet_ethtools_get_regs_len, .get_regs = axienet_ethtools_get_regs, @@ -2047,7 +2074,9 @@ static int axienet_probe(struct platform_device *pdev) } lp->coalesce_count_rx = XAXIDMA_DFT_RX_THRESHOLD; + lp->coalesce_usec_rx = XAXIDMA_DFT_RX_USEC; lp->coalesce_count_tx = XAXIDMA_DFT_TX_THRESHOLD; + lp->coalesce_usec_tx = XAXIDMA_DFT_TX_USEC; /* Reset core now that clocks are enabled, prior to accessing MDIO */ ret = __axienet_device_reset(lp);