From patchwork Sat Mar 5 00:22:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12770136 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1C01C433EF for ; Sat, 5 Mar 2022 00:24:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230202AbiCEAZL (ORCPT ); Fri, 4 Mar 2022 19:25:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230189AbiCEAZE (ORCPT ); Fri, 4 Mar 2022 19:25:04 -0500 Received: from mx0c-0054df01.pphosted.com (mx0c-0054df01.pphosted.com [67.231.159.91]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D281B972EC for ; Fri, 4 Mar 2022 16:24:14 -0800 (PST) Received: from pps.filterd (m0208999.ppops.net [127.0.0.1]) by mx0c-0054df01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 2250DfZo005740; Fri, 4 Mar 2022 19:23:41 -0500 Received: from can01-to1-obe.outbound.protection.outlook.com (mail-to1can01lp2055.outbound.protection.outlook.com [104.47.61.55]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3ek4hw0xyx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Mar 2022 19:23:41 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DRLkXZIBMIw0DAFJ8PgXwfveK99gjmKZN0uuw7lEf5FXnSNm5flXy9FzK4GErth+JaHUmAFBi+2hef7glxJXLMocAQUIwXnxJbi90AbC1gHqzV7pWmTfzoOGMpprcWpqe1lUvSqwN55xQOVFS5lgH8FSCDLc5wp6PBQLdJJCoTO7Iqp2EukA+A3Bu0Fkg86UtBKxIUi2TZtOzqqXH6jiJQa3ey7WKC//X5Ywc1nknuNxQlbkv4bQ0INGCNVjTKXxUNP5KZw2QW5TWiv9lfA7rG4mgmjGUdVYl4dI6vPJ5xtBkFXtCofSf5fKBClX8E5WKC4WADIQzZtV/mCsjPN4mQ== 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=CBIkJk/9TXcXn+O+fqlBZJWA719E0oawxEjjmo1OTP4VPhw2oOV56/sM+QB09uqMulV0mogjrVzkwtRblVQnSkrJO/QuPJo6yd8YTnAoUrhHQykiibKGz89XlB+cmJtOEqHWclXInklAthC4HymsLPa7hrT+YNDRxyiPXwI0X7d4a6xEJCjuWwxcOPZwcCS8yaWyvzdfgsezPZxYqP16YNC/zLeCXJ/h7gHhcQ5YgJ+r24jOYoUes0IwlIg28Uac8We0tiqE6H+7Qo/IM62oqo+Ikkj3qBaVatz5e/5ZQ2OI1PYkTniZngi9YM8/9Z3irpDAP9oI5Fpmb6dWYPxMxw== 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=Fwf19O2h2vR40SJDssqqs/017afII+zvXeRA/5Jw2ov8P5d2ovdWPhYHrSvX8I89MniiGUOu84ocJ2gmys9JeLs5Q4HM3spAXwVGmy/i+J2gkDr9TklidpbyiSVQ3tn0NwGYz5i2d3evvQMP2w2FBLmi3tfmk0YkgIrpoeWoRQg= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) by YQXPR01MB2758.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c00:45::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.17; Sat, 5 Mar 2022 00:23:39 +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 00:23:39 +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 v2 1/7] net: axienet: fix RX ring refill allocation failure handling Date: Fri, 4 Mar 2022 18:22:59 -0600 Message-Id: <20220305002305.1710462-2-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220305002305.1710462-1-robert.hancock@calian.com> References: <20220305002305.1710462-1-robert.hancock@calian.com> X-ClientProxiedBy: MWHPR1401CA0011.namprd14.prod.outlook.com (2603:10b6:301:4b::21) 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: d3bc2f12-0984-4905-4a04-08d9fe3e6563 X-MS-TrafficTypeDiagnostic: YQXPR01MB2758: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: 3s7LG8hCS+PqXC87PN1FSBc4bahSIecQ7t7s06pRtUAfSAC8wV2/eCbzfJrLX/7nFOE4V4N3tjTzqWVzPuQKWAStgVx1xWqZh3yhfrejoRsTHbRbjv1ahHA9UIx316itH+8qudBEGa70q1/v1FPMPu/Jbb9vhD0n6pVjKRCtuvdhv/Xl7/phSm3vwwzw7IGKLulVoQCQQk4KHNHFyHm0PJ5NXvHcH/j0DjUW12stHTD7fgcz0P6apmBzL3usNigWiSFobnQSroF+444/D9qtJhnLTT1SDRt4njfVf6DKo18SKdFYApZ6tM0Jd+n3NdQWmh6/mtzCbNoy7V9s4OGcdJz3mW2ia5H3d1OCEIDVZo4UPZixSLTaiHO1K7ItxVIJe2Q+FMFGrRKB66XSEqx8xIOx0KX6FL83IIxNayZw5mmj8UlKkyKdNHwSlZFiff+ON3fLxxCasARBJeTufg61FTMMfD+Koss62tD/6geEX1VU0vzrGi4TsMBa9jmLy+V6QQj/h8z41RF2OmHaxgjPuAf3RyQgNjLnWMgqiBM8TIdHcxVgwJSNUje4Gj4GtqGeBc5q37fCOD1SVfsU7pFQRaujdzupvvsMJ/WzF3Ef07u4B4EIv3yDlMxUVUUNe3d3NLskD0+b+H2HIvHAqeEB8vZ6Z1Yw6cZAC6OdpJEUEtKEm6F05i8Pf4ChaNlAsRTqcyAKu2ucb35aIabUEo28SQ== 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)(186003)(26005)(6486002)(107886003)(6666004)(1076003)(8936002)(86362001)(8676002)(4326008)(508600001)(66946007)(66556008)(66476007)(38100700002)(38350700002)(83380400001)(6916009)(2616005)(6506007)(52116002)(2906002)(6512007)(316002)(44832011)(5660300002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: K7b4HfiRdxeB/vVJfKoMR9p5MTFTl3di/1jrRVZYrOUoaxWjkwBUSd58xuFeqn0MrfuGdlHjyCX3NWCirR5LKvuFcQpDhhl1eRGMeMvXnL678QMTLKghSs8r8qG0clyPVa1Ae4m1m9alng8UIGwnTVVoQgFYLNOziJ8tLCpdhYtsOsjt0lMh8mH3gTxe7gif+yxIxFsbauK8K22cZMIFCbWBuxG2lvho8lbsV4bQeweEZuWx9JK0cD0E+HkOuUV869nDg6O91Y3Q+0FQivGKAqAXkB/vgVHfwUipQ3j2BKEaArPLsTifMUnnpITihwxjfqIm5WXxwMnXAjtggH81JgjHA+S72yJ21v9uiInjYMNpLk5ynSGWhMeJf2hDB1mpTNR7Ra5OdvUlhFxG7SvOETTDOFnSim2oDuzYrzmN9GK/JA1jSPudywdNNI69rMrpEZ7b/xt3iPd1EhUko/FpnkPCjnW1AimP2rjV1zLqDhtarmzQTEj7aubMdYXaDH3h+WcQKfqBn+hsTqcESb/LU+uvOgCFJN2xTtQQ1XzJJCI6jpZ1FB4oTGkVOyBbgUfpGHEnr5T4zAEvEcO2bE3+AcgZNMKtwOf2gT6Rhu78huzHxcHMWAdeBPixTHpv0+Vn5a9PCUwDuemVFde+UZ0YbrF+oex1shBLWtYaAijqo8JicbscLvfX/enp0WpOfsb0WxzMeZqJAn6PDiBznzfrnDR2o8magD7MTALI3F6I58tLoIFbFm5aBMBw1WMk5vPqkImfW4mWDZmf+STbYFRMoxzZhF9So1fM4+djvWPwSCa+XX/jvsC58Kzu768gUUooPBqs04r8/L1J006X2XiPzzLw4WMaV56vA0rvczvNLGJkZE0YKrfaB6/Q/Fbr4ehqtmU6jHGzD2v6bspSrYuV8Zq6j1YKpR+RIkOLyS+IGmCy6hzVvbGHZ2PNKVG4BYKvTALFKYp7fPL6w5jZFsulhKTcnKuc4qPWZVnW6tCGGq4Ir4+MZ8Rg+i3PFa8MEXZfWzHq/3P91/CB8ovezSlUdkv6TgBXFLmVeLcCTEMQRy2czEFlEemYHiVTClaGGBVvZckzQaX+O4GQQoJoiqYrgeMloixxY7UnGSd9ae59+2DnGeVdaKTu5iI91RcO2N5qkxJjXgsWqCdD0ZZGK82MvhUb9MdzfSJ1z690OA5Y6yXDP7KW0yQdMXZTpge7xzV9C9QdG8FFwHHpGK/lzX/Yk5TMFXZP5GyyYslitEPhWbbcek+QxYCZJ9H2qvlRDFLoREt2ai6B7ORL+j2IZJtHWjKPWeJE+WqEh+Tn4++4jEy8I+psXjwho1wKYb+YIi2Dvr05ISnfYBiJAXvsW+iOGN3kK/6LYpIFFIvEW4HMd0XMpRKrrBUk45sZlXjKuJSU5FN3NuTly4ZBSGUiebG3RRienXK4z1nSmxjy4qEKYXelvgtqiL9mvscoksgymGsHSj8Cm+BUfyS+OLALd5dXBDAjf28hyUS/sUMpxzMi+BmbO22h2lYksMSgdOIhAU36BR2wB/vaBEFJDlt0ckjg3dzWlEw+1SJ1/cdjDWnyQNX/YDfzSFM7wPvPbu9OxXY5+0XRAAZfNxa8B8sLowSO5avI0zSq/od0l9++vM4grqeBaU5dx8dSCpsmkl+zPHeXlFwBXfnTpTC46yhxxNInAHZAMFQsYdV5cqLAsXCw7uM= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: d3bc2f12-0984-4905-4a04-08d9fe3e6563 X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2022 00:23:39.3475 (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: hCSln3+EcXhGcZkaRkPAD+Blmrh/PsvDW95sTcaMaWhXT3PxVezEGMhP2wEGUGbnoGNuDDcCyuG0DVmzKJjxNOTd43g5LG6ilG4eDRXYZfo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YQXPR01MB2758 X-Proofpoint-GUID: y4EdU0KEc_NCEadrTJa9O7y7j0hqqgy- X-Proofpoint-ORIG-GUID: y4EdU0KEc_NCEadrTJa9O7y7j0hqqgy- 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 clxscore=1015 suspectscore=0 bulkscore=0 phishscore=0 mlxlogscore=464 lowpriorityscore=0 mlxscore=0 impostorscore=0 spamscore=0 malwarescore=0 priorityscore=1501 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203040121 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.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 00:23:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12770134 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA6D1C433EF for ; Sat, 5 Mar 2022 00:24:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230198AbiCEAZI (ORCPT ); Fri, 4 Mar 2022 19:25:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230188AbiCEAZD (ORCPT ); Fri, 4 Mar 2022 19:25:03 -0500 Received: from mx0d-0054df01.pphosted.com (mx0d-0054df01.pphosted.com [67.231.150.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A92997EA04 for ; Fri, 4 Mar 2022 16:24:14 -0800 (PST) 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 2250NPGj018659; Fri, 4 Mar 2022 19:23:42 -0500 Received: from can01-to1-obe.outbound.protection.outlook.com (mail-to1can01lp2050.outbound.protection.outlook.com [104.47.61.50]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3ek4hy8phd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Mar 2022 19:23:42 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cKEFQB1Edc7K3LI4f2LmbbDCPF0smOtHNGqdTXS5uCA93gtoVsysyVRmo9D4chZmPGMRMmDi8vZn4i2tL7u9V67PpjX5dTA7aQTegzcuvYLMJm+xycj8vsd06MlUX2UcYFDzKUhSWhznRjzWuLTVJ3uBWaAzEsjWtWapwgWC5OS5PHHE2lPEXmN4+jE+SB3pfM6gq2hpY7qRtgJL3u9nq/hUHQR5Sv4Ylnch9aQymHRtTxfq9avHzxZi+9P3zbO0prcyZMMLzm9OVPloIVVVYHWMdjJXw/5wnljb5xPqeWY/ZZMFRmN7tHpFgkmrP6+DR0CWrz/9ZTm6RpcQYTLiFQ== 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=NFSX+hQSmdD9cJEYaIa+tInaKZGl+Zy1t/mPTJS1ZCmTV/nAk1+ax79QgzofK03/UrocHfdDDGym/oxSCTXS6N/Qtm0OJfzgj1OqrJJFpvF1AsYVJoO3elL2hZn7PMbPfgaCdVmBc+Y3N9TcUObcIGYzwVY+sTgCSB1EVr3WORpVs/m2mpDstW0a7oxIH4SVJDFW7zNp2EnGmo1oGekt1Y5wHkF32yCFST3HsdeN3SaONDdj1g/M32q8zLBEu1u6eLtuVQGWl2z+dd5Ut21hLBRSYTG8q7YzYDfeugWbyVQK2M/17KdLNJOmElPfKBRW0VtU1um4flgcJeDESjRtww== 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=u1Nf/026ppBYD7HAIL0gHpfE0irMu25+GeoIkm8swTb3SkYUpwJgwr7TzIJkKfG4u9kM/9t92Uhr2QRf7Ex6rHZkgDthpSmBMD/4WSDl28lJpzJRvXvuQrQttRvljjEdDfEVQJW+igkIOQAqDyLf7cVIvilVPDudBuwiWU4Ch+w= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) by YQXPR01MB2758.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c00:45::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.17; Sat, 5 Mar 2022 00:23:40 +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 00:23:40 +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 v2 2/7] net: axienet: Clean up device used for DMA calls Date: Fri, 4 Mar 2022 18:23:00 -0600 Message-Id: <20220305002305.1710462-3-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220305002305.1710462-1-robert.hancock@calian.com> References: <20220305002305.1710462-1-robert.hancock@calian.com> X-ClientProxiedBy: MWHPR1401CA0011.namprd14.prod.outlook.com (2603:10b6:301:4b::21) 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: 22552214-4ea5-47b3-3e0f-08d9fe3e6654 X-MS-TrafficTypeDiagnostic: YQXPR01MB2758: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: gydTeFr53bvivkTa2ciB2dWTV0v73H0nFYU75E+sse7XdqvFFPBBnZX2BARqLdFWXBcT0gi5MD8K+3Lp+ZfaadFnfXI8LJL4KZmX/o9ug+q+wTTisPURh20s1VPBzUX3JVGoSzJomIi8TW/gNT/kyhmFZtGmuewRrXdZR0HNSZWVdPvbDp6VADHaIxFnkHvgaP8hcnmtGL/T7x76VqiSOMCczGlbPQnlCUFyy9cFCM6h7oaeK2O8kWZOSP46nAbbHXBmTmznV+3IOBVb51T5FH67BolWQmvb4wXvqd1zY3+S9XBqCWyF/JgHUitBtD84r4XjcYoFf41fHGm3mWbvQfHmx1fG1iYao89/WBh4wjk1dYxJ6E/JAEyMcwislpjJ4tGCIGSp7Pljg1tE3iGKvpt5K46/Z47Ci78KsomgPR/v8HQwDFLAs46stQSFPe3LBBs4Xe0ky/pfK+6FhZKmuF+cmWCGPUBaF6sIFRRfwUwyFUf2iMTFFpO8AROOZ5JIZb1f9wxKFlHe85AUIojuJ7uPZZqOs9/BqvLAaTKuM80rFzfr9QUQyaszlFcSuuySyJRwehAAOyqPGwylBy7TRgSd6XaTKBOXlBOlVHr4Q2ht/W5fgvVJ4ARA/kHvKpUWnx0Xe6ZdqImgMdsRXH6lw/oLJmLhEhLyY02F3p+azD1D/HItYIngP01sUoH3kFtX0lkQgtalVqZl+WChCnOB5Q== 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)(186003)(26005)(6486002)(107886003)(6666004)(1076003)(8936002)(86362001)(8676002)(4326008)(508600001)(66946007)(66556008)(66476007)(38100700002)(38350700002)(83380400001)(6916009)(2616005)(6506007)(52116002)(2906002)(6512007)(316002)(44832011)(5660300002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tP16FFzq+P8+l8ukt24zRcmcij/q14/79mC4iuz4fGF/mytAmM8Scp1hzaNP1w2YumTP11uiAwdZCqTCOE/uPb9ZsamLoHeHn7W/Jerq5Jhqc/UahbM9MHy3l90cK9wnUT2YyNn9+TgBXiz0a1NrUjiBZjt1FScYMYJeeu2TQtloJ72E3ytoIcq4AB9dzQCCqPHNDgJIYuKIDNkkfI5Z40WfbuTt8n2y4NKAom/1/WE2oWcR7aKDN5ehVI8ZZW7mIy/xwaYw1/qTB7vs5XiBxEpfZVEQHI6FYeyKycbXHoRwCggfVXQUjvkf0dZfAa2kI09RSIDnq9tTgUpWppD/wqk8XKRDy7NlDSlfWAP6BRSmYuFySf5YYyMBhECNxeVPb0DbCJX5J+UbY5rsnhizIHspJUOjuMVD3qLNp/xcdQdqSwfXeEFNfD3u+3Ztrwp0q4gyQthb420aocp+SF842NCt75w7hPf5Jr7d+PAYoRD4Wx1URJvFivQfCGXEAQkR4HKhBZRmZZiYMHPxp4qSee2nOv/PV/1CsKhbIwUDZr5wZyUlPyhmfx/JTAekuduYNwjGy3Yz3gfAG+2GUbJyc5XGBwhkADLNts1eJjC0687f790xE2CWVgO2Iev7bX3/0Kfe3Gx8Oe0LoGl/ky8CfctajntBVmxvLRXq8cF9BgYT1DMo81ViQQ0PHe6hkhR0a/p7umQeCZwROvMXHlkMKLcsg1IlMEXmtStVWMvwsYVM3hbDerS3qOA9TNcFTypEHL23X2R9kv3eikynIvcPqchAoNmRXpomUuE66TPXmmrLETMel3cKnReQsUKgrUouZ4owz7FJ/ZUtrJVBZgjiwJcqbu9VmXW/9I3ZEn9vWsgruZ85E7Nc+qToeqU03cl+SbJWFBcuzRH80csegcpaNnInHiQ3aDWJCIExwrSxHFOLKO7+3ESzKqZdPaFOYbKNTFzFh1V6Gk3OKAbN1BeUI/ks9O9qCvt11pzJ2mzn0X8vBUrmxvn/HcSjfyuXDqraBrWRPI3XKaDTsI2blvGEu111rQ0XI8qrlfGzFJjTSBOSONs7pn3cM2DSvXT4Fuis7T2mu4/Zkft3INOh6H9BpB/uekiPaZxCkvlGHuW+eLJXtIVIqxf/aELLAlGvbrh0wAxA/aWXQcfULMHk6P7GdhapPfa4gQFINOsykA9VN6iyVZj3/h+xP3GH84LxCmZU1r6nR5Z4y04j7DiOTXqfb0ZbPS7ZQy0r7XuA2VvJXP5TxBrBAffoELonDQ3C0m3BCSzv0YvrRmkRZN51U/5BzfeEC270m/ByE01y5/41hIvlwq21yAwg9OYkqHy69TEKJlgoR8DtGmZkQBc2b28+RP1Ep/n1rccv5aJ90wiclkUhpSkZhDyZGkxVSE5QeNc2shSgCJ9gFPgx3r6ODyAN++gNY0wum+RLpyOz4LV2AxK4TSLnkkdZwBnx+JqlWtz2Ymstm4yXuwcc2dIpy24kvSu9btk5VgCeGAHg0IEpL9wJhTC9t5H5RF+wG4asTjzqnkXxAPYhXzUSxIa5OyrUW6VGZY3clJpOUo4vB9PlBeSqqgaR5JpTIoMVs7Y9u+neogtp9PcYeB51A4J/le+tJkS8nfDKciXU937ERNNfy9F8HwJfPk7hb9hU4ZLV6ZxUiyGccbNu4/Pxl1WkCKGPN3U97HA5jMK2GqYwHYuM3uQ= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: 22552214-4ea5-47b3-3e0f-08d9fe3e6654 X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2022 00:23:40.9110 (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: tlSGyn0yx9Jz8dgUWOd/iXhzvHen8Vk+yDWllAePsBvtRZlqg2vWLz8ID09AVSB+zPP425hLocYwRaBzkX/Xb1eYnGr2wqXtgVBbbFZKWxE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YQXPR01MB2758 X-Proofpoint-ORIG-GUID: ee6k4DxvQw54m-MpEzj3FC7RGWArZ5WE X-Proofpoint-GUID: ee6k4DxvQw54m-MpEzj3FC7RGWArZ5WE 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=756 phishscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203040121 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.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 00:23:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12770138 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 622B5C433F5 for ; Sat, 5 Mar 2022 00:24:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230193AbiCEAZP (ORCPT ); Fri, 4 Mar 2022 19:25:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229582AbiCEAZF (ORCPT ); Fri, 4 Mar 2022 19:25:05 -0500 Received: from mx0c-0054df01.pphosted.com (mx0c-0054df01.pphosted.com [67.231.159.91]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF26AA1453 for ; Fri, 4 Mar 2022 16:24:15 -0800 (PST) Received: from pps.filterd (m0208999.ppops.net [127.0.0.1]) by mx0c-0054df01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 224M4Hd0004102; Fri, 4 Mar 2022 19:23:45 -0500 Received: from can01-to1-obe.outbound.protection.outlook.com (mail-to1can01lp2056.outbound.protection.outlook.com [104.47.61.56]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3ek4hw0xyy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Mar 2022 19:23:44 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cx8fZvdg9Mk7XGnmwkwmURVV78SFkCPiqlIykVz7ewODXVSGywnb/q5F/mlUIHc/qFHU3WtqefgaUP4WmzLNvwpDDpfrdAc2t0j604LqbzQXb6n4P/Yhve3YREHJDkUa3f25AVXAoDkPGYpdTwWqPp4L695Sr7D6nrP9GCTgsePfi+sE13A9InHUkKGr7Tus7QB8xqHJ1vQlHaASasiiZJNZ1y+a3k5TzNVD/0uHwk5IewNEK0GMY3hquIl62kJqw8e6Cp0IdLGb/W7eJllUdo+YtoFTCrsJwOxwk7qc2dIJGiAdLPLBYw9zLBFB+TRatAEOtqZfkGZRSOEOJCwRjg== 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=OlvEzMp6xWlq+jGpsEFAi948UtN5T9gDayRgj+ljaYpqo+gpNJ2EMMeaUL2ao3Qc4XAACvkhE/0nNv4tR66nnCiVs3wmFBvopmgjGJAW6bd7MjQu7Y13GXatFyXzpKPrmsdkCXB5MXr9WA2e+9YYWzRTZmGYFdTH6kGkIl6MS5J+ccdc8D+/4kP8APpPSM26dW1Yah5kVCT/d2R81Sf5CN1Bf5EwYrTVeriAdLFkGaRJRh9zvUSvMKc+2sLbGnAMCxZuZXaV0tvn01T34SKRo3/J/AomsK8ix6o3pootkv4yoZLmiqViCOpqzU03lPGIBlHgbgMeH2BdNpCPQ3WLIQ== 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=kUnh+1Fbx2B4xv17cuMEyPzNwHUnZfVXIQ1M2A3sTiayb4uaCo0llDkVtUcKwH3ly9+JoJdg8vZ0VMJ4UWHyOgPzrMdYFu8/Ij/ZPgWoblXzqG5dNR9fGBmWg1ExPgB2xKOd5n4vfIN9LeidxzsBJ3tPpYAQagru/x4w3+7RhvU= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) by YQXPR01MB3701.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c00:4f::19) 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 00:23:42 +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 00:23:42 +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 v2 3/7] net: axienet: Clean up DMA start/stop and error handling Date: Fri, 4 Mar 2022 18:23:01 -0600 Message-Id: <20220305002305.1710462-4-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220305002305.1710462-1-robert.hancock@calian.com> References: <20220305002305.1710462-1-robert.hancock@calian.com> X-ClientProxiedBy: MWHPR1401CA0011.namprd14.prod.outlook.com (2603:10b6:301:4b::21) 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: 6422c8a7-ed30-46aa-5ef0-08d9fe3e674c X-MS-TrafficTypeDiagnostic: YQXPR01MB3701: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: unwpeX4kOX0G+5xFyRF16zz53tTYiNRs7uIfS4UnoKJrQt3rFFhUO8bpxNSSRtwVjNyl/5y0+1vHxjv2v0sfb0WGOid+fusPOLngtxQlIIXQyavtPJ1cqNKH2F2OuqCcktxP70/xZA1fns2LcjLwxVSX2i9HKaekkRk6D7EC0Nvw8+TIZ20IhxZTofE3TAs7Ahgsg88kwn+4XbrOpDYqH8G0eZrGd3f6V2wUMrmEOjDtUjdB6Kwuzy2XIgyutQ369VYSH9/4vpLkILgaTawuqxymC3vombi70lqqscg0gdg5ODdJBBeVUDuSejdzSsfcdUzgOTy61SeZjYMCr/EmXut/93oNHwE9KOr8Rksoeei+QVm47kSXhCKxo+TdFdL51sM18SFkxq7KxdrmMLwUIqGnKtiATXLgxox3PjRMRMSnaF4/onsA4OwGLz9pYM1bpYlbQbgCPEajPAeaKj7EwEb1qZJPRlTjUNDjl8rjpC38rpl7RoMC97tORsNg0FtPg1k/5p4nfv8SA+WrLuO+HP7bZG11ARA0ZgDuNyq0C7qLK1hNAbyGus/JiuZo74We8kO3S9avKL0soTLcWCUxhAEpbgJfXnwx2xsOcnQQVur0cva1hc8Tg5ppcezuqYFr110BUbOYfDorgb39tbxyMW1uq4c8cZfQEjaqMW/0PNDub3IpUI0w5ecf9eEGJ6U/p0SKShBlq9i1pi0oSxt6sQ== 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)(6486002)(2616005)(6512007)(5660300002)(52116002)(44832011)(6506007)(6916009)(30864003)(2906002)(83380400001)(186003)(26005)(107886003)(8936002)(36756003)(1076003)(316002)(6666004)(38350700002)(38100700002)(66946007)(66556008)(508600001)(8676002)(66476007)(4326008)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wREy5unGbVyuv1vuZoqZwyakrWTiuBof+LYn5Q0MOMjMB/Uas8Q8xmSpCHJr699D4Xr+dUj1L+TP7sNiLW8XsBkdx8XI9CXjpCWTOCdM9g98o8iUgCc3VztKTbBZkSX7QtUqMyyvKFyrkuJilJBvcI57vXaVaN47hT4Ab1iiXo568jRvuPuh86Kkx99YNS6l7CppY0IphMykVE+Gzd+ACGx0tYUP8cegGIm4Q+VT/7qHDEjRWkdm8DqqwOvfJwVLPqgDsu+g8AS9Tz1r0JEYt+un19BIH5CLTWBsrWJ0haoEngomRmPNI/GTFN7FyqjJ9AVc+Ucmku4BtcLyFEguPsYtaU4l5oRavU5JiVnmUaWNXEctx+vrxaxCkYuOt9/bomajAl4eyOzx9BLlQLkgk4JxPQqXmAbUfB1m7OpI8Xf1c4EjPjyFymWY9T74NWHDtrDiJNGEH+DWQAV+x5+PIt1DDs1QV0lyDaJqt3swOYiOjw+9dEB+QBes54pPQ2ywv1DmVNbmo6vmyL78bcZLIR0HODckKSsNJiKv1ZjjJ0UdubHgtpSTvDjnnuz+/6Y+V754eP5RfIp0lhL3QafQfSh666NfXR4wfeZ0KuGMg9l9Oa4kDIzgt3dfpm0SMWLVBxbLD9EmFcloAFB33+0JxhkHhs4UK3gOhlttizT3Ulcok9Ps7KIyTJX3wvF7Jd/viAimjo+Vk2j3D/RaH0U8Y+SfBOOq98Q7FNOlH+Rz1JvLea2NJP+Xqj6ZUgvPZdAInZ4DAQqplhEgKJsjoQ68PvQ0UeF+MtWMQQ21L5PKM3SekdJKsXciH605eRPUYOfwt14Hl87wFkZnZKD0qqzovmMB/BbaTJDVCjQPuPmQk5BH9jZ47z4HR8mAiAhgIGWxq2JqcLvLLYGRli3dCuPymVHeke3e5i2J3Vh/7DdHqzDec5vxO2p1X7PhhV87pGCrusEiME/A8X4nqnXThTD1y2zRYLZk0Zv0JYA/uu7A6gKMSoTUPuVUbXFXj5N6ZWfiEengI+SzSUe5oyKX7d29MCJdf/62ri4ZNoD9W5b7A8CUNQrJHhP8TTDKZsBqvHGooFgn7gxTK4FhOS0da11syEhZridDt8yTC7EZsCm7kQyFijqkMnZ1TfzUawSJJpjfcqLASOQIvUtXm4b3N67pqjlk68EstVKlgLfjKYYSly35dQKAPM7o25jTwpgJNwpJGIbs5I5z0PZaoP30SDkASidD5ZWlRBgX42qAvcIbtLVOpOMZmvaAjjg4RdETanawBYniuYLaT1R1uP8hJa80fjY2Cf1PQKDA9D2QgSjCr8ZK1Cu4RZf5NTKOvgj6mXBUe7nzv2cFxGeYdcqCefVwn0f/8Qg6OLd1LkOML+k/r221+kPrVgHiXjhATApkiZ9s+0k3SYEI/ztiVTibAN/TVWReVcG51irItEMQMfVzqFxQMNd4cbVVY+Fl892vWn+j54SYf8ICEPoh5mI+uGohYLrJDuSTyHfUGU829RCN5LGgcn/nLaUF4OhhYujARTMlrzzuDLsEeEmPzkb2aoBgtjSb6jTQqE0w1PPWJ7Rm+JI8z1tjmSrt1CBx0GKgfClpU+jN2kpS2q/p2AL2wb0h+ykrgwdmbxFPU8c0yvx4y4CGQrMV7HYX5bEjlIGXLrOVsO7Jjpv9iQ3TwWsfLbnSKB/dY1IzbCjVQqPGofvvGOA= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6422c8a7-ed30-46aa-5ef0-08d9fe3e674c X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2022 00:23:42.6767 (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: xUum9s9eTNCvl2O09WfRp5hOAA0eCVHMw18QsH8RdwLH6QFowfJY2zGaqZ0DiZRbFf1h2L0XCDn511v/04XNAH9SZFZDJvALkgcoEds/sPg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YQXPR01MB3701 X-Proofpoint-GUID: X31M7-WDdr-J1YXXkjRvOdrMh_TdKPwG X-Proofpoint-ORIG-GUID: X31M7-WDdr-J1YXXkjRvOdrMh_TdKPwG 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 clxscore=1015 suspectscore=0 bulkscore=0 phishscore=0 mlxlogscore=999 lowpriorityscore=0 mlxscore=0 impostorscore=0 spamscore=0 malwarescore=0 priorityscore=1501 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203040121 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.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 00:23:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12770133 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 731D4C433F5 for ; Sat, 5 Mar 2022 00:24:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230191AbiCEAZE (ORCPT ); Fri, 4 Mar 2022 19:25:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229582AbiCEAZB (ORCPT ); Fri, 4 Mar 2022 19:25:01 -0500 Received: from mx0c-0054df01.pphosted.com (mx0c-0054df01.pphosted.com [67.231.159.91]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01B387EA1A for ; Fri, 4 Mar 2022 16:24:12 -0800 (PST) Received: from pps.filterd (m0208999.ppops.net [127.0.0.1]) by mx0c-0054df01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 224M4Hd1004102; Fri, 4 Mar 2022 19:23:46 -0500 Received: from can01-to1-obe.outbound.protection.outlook.com (mail-to1can01lp2056.outbound.protection.outlook.com [104.47.61.56]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3ek4hw0xyy-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Mar 2022 19:23:45 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LhDmTRSkz1Rz2mXOO/LtV5zsDjiSr/paStVFHReM6BGE8b+bsJQyGmHWugvVP6iwzyjjl9HhklqzXpVisDv1AQ4tagCRPgXOhtabuznre9AAhjTdv9RD7lVPzksVmB0DY75MWpdtRqMT8RgsZ9cC6p+G6obGj4IqT8t9fcp2lcYuU7soS5y+KlwZUp2imY+d0jvIAQWLbmhciPFYMp7nP/bkz6cWEgtreMWDKKQV+D1+C50m/v2nLZrdhRYvrVi97HBrbtRWZ1F0Fs6jto1gxYObcM1Y3bPHtgNuoFcQEYPd51VNKxZOt2zXXUMdAOyJ0Q0TgDVF0kKn87Zbhx3/jQ== 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=kdsZtoFURMDyE4oAyM2fcHGdGWT+KLv1w70LRYgO+RYYVOETuh65kqfW3QqtTlCLygC9MNjnYTd1LGdU9lJ55XIghgHGrnj86pFEczMbA6cgztHm+jnqcwz/dPdD4lPdoI/1R1Hov613hGbJfgRpvrbzQbCdRLr5UXLNxZg6hva3z/HzXZpNHmKokDXI+auU7hG7rKizPunHwr6Z9vhffy2X6gCGGoC+nJDOU2WPCAlc4AbRlp99xAAQp7OjxlKo4IkOj+aNh+27zqGRcjic2wdBUb5KrQKgO50RKYYOzy5Wu2V9CtM8Bs9Ovzw3LXC1cU0xDozEjvIC5QNR/eIFmA== 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=t79iGvKljn+RqQeJgtnE5Xli2tjVCkCIQ6CVUIwjKx3PqAWbw2QBgHW9nMWOq7aHA0NDcUJpHHDZ6Ot0JTPweC/pzcBicD9r9dQUAlGU3xt1QjBjIkbtYVDL+Ntc0oHNZULlCfxgiFxs1OGLJiz8VKhXFSEVnzQzAwWD6rF9ecg= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) by YQXPR01MB3701.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c00:4f::19) 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 00:23:44 +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 00:23:44 +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 v2 4/7] net: axienet: don't set IRQ timer when IRQ delay not used Date: Fri, 4 Mar 2022 18:23:02 -0600 Message-Id: <20220305002305.1710462-5-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220305002305.1710462-1-robert.hancock@calian.com> References: <20220305002305.1710462-1-robert.hancock@calian.com> X-ClientProxiedBy: MWHPR1401CA0011.namprd14.prod.outlook.com (2603:10b6:301:4b::21) 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: aff40564-7087-413a-9ff8-08d9fe3e6852 X-MS-TrafficTypeDiagnostic: YQXPR01MB3701: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: 4fNr1N4EZs9Qe49ogXL0KlwzZK54BdnQUvQ6V2u1T0kwTNbnJkW1Xq3+r/QOy8rlK/V1nUUYeCe5ZXwWrUrT8AD1VQy9DhbSV0z8ydifP+CQ7z0wklPuqsXHytfWMncGwEiEmKbL/9GDbC+3yFAYTt0XKQF5aKmIP35+lBb4wcmjpS4Qu7bnwoABIHX7zhjDu8EghjGYpa8hzG09WRdoG0nfYckXJu94ckcn1yH7saNvB0dvckSLuQRPte1tfRnudsA6u/qNfHEfRm5kO9oyowJTgiJTcEMAwrVrAxfb/zZ5fX34QOO8KOQ2QoJpGfXYLI37lJ0yjxUBYZU857HqmTirCeTK838ashMghy/J5lF6Q866vEDwk3JLonFOCZQk41a1Yte2OUpWHzl82Wop97bCMTbhciHcOyIeDKZCnbxuW5ev4gXmG9ufzWSgCkcKGzFsAu6GrAcYUmI3g+r3CTU+natXZPRi3UqTD1uojDakEEFI/dLEBwL3rwZF3YIvVaBMfulM76ar96N/hv03PV00wn2WTQKD0mYY1q7KEpQHSfFV81NCczoYkWPr3ox5PnRK3jC14eS059GdSxTDpxQvLnhq6i0sZw+aO9R2CzkZJurVMhSpPUQ4kTwY43XI/iVgErFEnSQ9xIPboVwrVDezbngbQlTrPkPEQpp5/yeVBYz7Qe0XU6wmJmHbvQh4LfBierYHVFe/PAvEyIhACA== 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)(6486002)(2616005)(6512007)(5660300002)(52116002)(44832011)(6506007)(6916009)(2906002)(83380400001)(186003)(26005)(107886003)(8936002)(36756003)(1076003)(316002)(6666004)(38350700002)(38100700002)(66946007)(66556008)(508600001)(8676002)(66476007)(4326008)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ldmACn6VFzgx+53+Zs+wpe+FOpj1wapKOkSWhmYJJkIOnR5aY9a3mfoIEoZrn0wsx1WhirfyJcCCBnU/R83/Yr7WfILuCYmVGq4fQq/Hn+XAryrWbIaE91YGUDV0fsZiqCmUZoggAlX1DE1TigrUGSENK6hAx8zBDa8FtBj4zRCzb0rwpb4Qcaj7cAomdK6xgWLDCWnQyI6/KW7JyK4MkzE5u8ZcJBxWrHA6d7El7Ka18F7gE+XaN/8OvETQnsJFV2603uyrf8S87jTBivtppQA1dEHMmYTNEdC6OGvHWUwmNzRajpfT0y7Mq3eg89LiFYyypWhXoQDeiIpxOt3XlENOSS9kt6rdb2+uTbhWi7g2udLcv1DWaLUrtXoL3pJ59B1Wp1eh1OgNJinR8BeSWR7bVMJ3WcVaVc0RYTB+ryiL3O9KaMgDrfwVoN7dBvI99QmucVXuyBwQV4aj1EuBL64Yqw0jizS8MPMoTF2nsSgIOJEcjqiYudVEIKuTCBZ+4TaVvTfhMgTwWzEj19zU7XZAfKqxwJ85V27rsiGWNLCkuOQp7rzRjosQfi5hTdTTc+nXXsaJ/GaPeAtTGwWvXjdeRf2e7vArYlojDCF+gkpacb8Ieflc4pyxH4dR+XMwp2MR8nkMff3h/fWy/xOboIOwssci3eVs1FvrlOXSGJaxVOVSLNcWPnGQfZBaIKJ3j8PglFI+O9PcYViCHSEDM6BznLxU/OCBzETddApcu+jR5pZD4kTUKXSlshwszs84QQeFO5HCN0KTuGiJZgoR6irpONJ1fMymGR4wskOV7nAEGdB2Z1aY58ZoUmbrZR1ztJUYdAo5vgYFe/Wyi/L/EPYzSt4ALxkCVY1n0aiZHodq4t19vlrgzxeAgwpgL66YKbrf7nX/rZFTEuwW9T5cISFS+L/vEvnAP8VvHQ7b4Je2GSQ6ANFn5S3ORmbH1MN0aUV31F1FDbqsLpSpn+ub0ZwHmrmadimsNCCWhX4HdK5m9F3B1Oeuee63FcMrPj/W09Lm3x4iKc4DFF9+8kgjQbzZs/Z5R5w9oXaNMJ7Av+h6E3+1dHBVhmKMditY7UDitXkBvA58GpK9ov/YuVNxgiymnvXY18CtJKfFHYKByFc5jfFDnuSZdNO9VvXSboFvWnmducBdBSw26dBD1OKFRuA+HLHO3+RjzSXq3zfuzESg/s6I0cd07zI6rLKNmYuIuzzVzCRBPbl+upat+IVg2bPnkiY6w+B+pFoj4rZ1wtPbqTfFaufBKmHE+nvCEdfbR7/FZcWmg/njfUFqOhjrZ8fXS4lddLS3Ts4HQ/CWKzOKUylC83iTu7YLG52w9QApvPNT5ufkL+fclsNgoO54fVj+DAEEcZoH6MHfsSUNMxo9YEKPspCT5ECFEnz6QtQi5SmzlyrN2mdDQgi05FWPXSldqCja5t2rymGZkahJBEFQcdkyCXWTmHDjqmPtODF85z7nsRfpoxLiKW0hoARuY09A4vAoxwq/owEdQZ4bQL76mnrm8rGZvPwZSjcaC9f9TJQccza2SS/crTCSkWhHxxKacPlKNRDK7S1QH83WB7tncZMBS/0Sv31QYITsDM/mbewY+1D0JMPEK/aJhBtCoeNhaVAEeOkY+s6233v+CMG5RokcNBPG2jkIYzD529UFnylvzwlemDQb6zdC6JC//Onm+rkxNg3G4hQsJKnIR/Y= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: aff40564-7087-413a-9ff8-08d9fe3e6852 X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2022 00:23:44.2402 (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: aMaNaRvZdQWovR9NHUalgn7Fh/3DB4y+n3zOS2Vnmu8WuftLZcWVuAC20OWlOEpFngGxBAhiqGp+8H6SPDi5OhB9iQG936LcDU+2atJsxRY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YQXPR01MB3701 X-Proofpoint-GUID: ZyvsXpPTXZqIWsb0zIQDTsuZbY1sPbMC X-Proofpoint-ORIG-GUID: ZyvsXpPTXZqIWsb0zIQDTsuZbY1sPbMC 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 clxscore=1015 suspectscore=0 bulkscore=0 phishscore=0 mlxlogscore=836 lowpriorityscore=0 mlxscore=0 impostorscore=0 spamscore=0 malwarescore=0 priorityscore=1501 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203040121 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.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 00:23:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12770137 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95283C433F5 for ; Sat, 5 Mar 2022 00:24:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230203AbiCEAZN (ORCPT ); Fri, 4 Mar 2022 19:25:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230193AbiCEAZF (ORCPT ); Fri, 4 Mar 2022 19:25:05 -0500 Received: from mx0c-0054df01.pphosted.com (mx0c-0054df01.pphosted.com [67.231.159.91]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C129972F9 for ; Fri, 4 Mar 2022 16:24:15 -0800 (PST) Received: from pps.filterd (m0208999.ppops.net [127.0.0.1]) by mx0c-0054df01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 224MFFFi026604; Fri, 4 Mar 2022 19:23:48 -0500 Received: from can01-to1-obe.outbound.protection.outlook.com (mail-to1can01lp2050.outbound.protection.outlook.com [104.47.61.50]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3ek4hw0y01-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Mar 2022 19:23:47 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P0BX/9b5qX1sbHOTGyuwEf6P5SPuau4cZ53e3UTT4soL9/NiAtYQHS1BJ9aN75hG407zgee8T/YVBEtwio+mVUjnsiQGkx3ZnTlKSFwdLapUn6U+eGJqXrcbkENHKJjWui+gO6X46+Rrp+ZTFtVRFBH2aYd22gDt3cYYoIXi932IG/ivFfgL8p4RkNTfuvo61r3hyeNv0/dCbPLFDiOtxey+DuNSTEP9SmCKmwAFmn+zdXVtDWH6oEQuWE1sbfmTr7UiUD4EH4m6DQKtUAZixmtLDBgGZ0mywSHYY7k/FysxFw1uWCIGobjYUyWBq9cD1PF3KrbUHH2x2bVEc8HjxA== 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=m0mpdYuKdytYXa7k3W+Bj6/8vT9EyHP5v0jPf4hBCOZV5hY/u5lmyLE7vSoSp6//454hoHwCCaIv20YnLP0uubEUkO9TrdB9NKE628UOy5cY6IaI7b62Zj65km4xXFRjZa5VuUifU9mkjTGpczjelUss+50Pi4Uf0HlDgGWwzPIreX2gQpkG1PrB+xbPnraQVPg39Xa65+drAl4Rzkve86ZRTSXiUCEuUCAXdQMXiHDb+1UbXHNrzERNsEexfnThMA3QoY/uk4iRAkhFvzZssTIZ/jeA8U4xbm981iuZVFlW5FhIdK8U8Sd8mJ3c4reYMYZR9rAfT1jrWVip1s4f7A== 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=RaGZip3Oo4gGVjDnVU+8Wii1d9ZCA4Yyv6cGKN9D9hdUWeVJUlmcFcnoQL6KsiTbBLzaFKi6TdMh9Ld0fmrLlvAHySM875g7cfUz+/g/buUYI3D/O4NfC/7U/7btQ73Lr8QyHpi5oMaipifZiO+brXkCGtPUUmSfmKCB9l9aInY= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) by YQXPR01MB3701.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c00:4f::19) 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 00:23:46 +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 00:23:46 +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 v2 5/7] net: axienet: implement NAPI and GRO receive Date: Fri, 4 Mar 2022 18:23:03 -0600 Message-Id: <20220305002305.1710462-6-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220305002305.1710462-1-robert.hancock@calian.com> References: <20220305002305.1710462-1-robert.hancock@calian.com> X-ClientProxiedBy: MWHPR1401CA0011.namprd14.prod.outlook.com (2603:10b6:301:4b::21) 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: 84017324-8ba6-4336-cb3c-08d9fe3e693e X-MS-TrafficTypeDiagnostic: YQXPR01MB3701: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: Cv/UaP1/qedc8FVXjjrWvmePHJPt7GEcXpe6fmIbGifbA0cIGMLwKFBSo3DbeHMKlL7T96WaKzh4/40LvFGNfUEFVL6aApuu0dMYLyfFIMH96XYmCNFPvJlKvYmKGD+KWZ3xWL4WLry8eRg7heQMTzeliOwqldAvr0BcqrOolYOyW/4RBTA1hh/88HeDZpQ9TDjeZ63PjTQpJQtjknuGtp+ply0hD8cPLuq9TTsYSjAq3gj9T8ATEP3hQOvpIpK3TS9gICX/4pMIXhs7btsOGujbuuTOzzdpQ7ZQfwwQ84i20sgFxu2k9earObm8m97Xb8EtzlcgpONZoF/r+A6RCjt4b0jfLIVHSyfj/fm3akZz2RJ68PkuI+m3uUrtNuXJGyYgIdU+AyyAKPw8JxIm+5ipaRnPoGyTzOzvAjW53pVpVUQApudWCdrocNDbtp6VKJx166nBJwTcY06irEv2rsCgMEoZv+qeAfP6OIiZZGjJjHf73Ljai/Fn5qHrTDQd9RuK+nrTAXp+DrGZ/Mz3kmLRzL8l6jCSUgrUIZgIFm1LJm59zw4FeAZI0cTVcudtr7MSmgdDMqurTx0ks8QB+igzGvy8pSgqVXdVONriTTeor7FqL2ydxPn+p6kBX2b8Sx/HbBP8L8hsR0Fmt6muuO73gvbkMKRIXt7GXwnG0DhgozWOYu9uyoU6PNDa3hcRMvqQlGa6AQjSTuS0ckcWhQ== 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)(6486002)(2616005)(6512007)(5660300002)(52116002)(44832011)(6506007)(6916009)(2906002)(83380400001)(186003)(26005)(107886003)(8936002)(36756003)(1076003)(316002)(6666004)(38350700002)(38100700002)(66946007)(66556008)(508600001)(8676002)(66476007)(4326008)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8E6KPs3FIA/fjA76x8wUj+JSbejPtaG+8uDEzkjdkfjtlGqGvL3oKU45s5Kl9acc4GpJMiJsybdgRvYXq5hMgqpSJNKGyqnSIKwnONYYKGIsPHqk+IdQqerBLNX+ZjWO6XcXdrCmuQpP4eDetfhBimaIqVDvcsfq9o2y2con8Uu/dPE+OodJlvOl8bfJO0iarwe6NXRPP7vfAI1Q+BbVS23x0XWRvLNHeTDdXyEO5KeJKDDI4tH1hg0ex7mEQSZu/dNBsb1A9Ps30xSSFmB0c618K/onUflNPEi4iqVVBl5yU0PThLHGUMMPguuwI17qtxZyIv6mqrqavxyQEyaz8DaiT9LcFInxOh/F/ane+pIzCxlt/C48yoq51InVdEYWJOshl39rf/bMOEsI4Kn68v65xK8MlqmYduJYnwj9oh2sr2gOlZ0+q3mKTUp93gfr6Uqy8dDeGxVwUexerJzR2uoC0sGGFOMkdV8LAy2qr8VVQzkFuwW6ILK2XGGHJEietOFiaKR7CxS4rEShkkZkDq7JssJ48LpiEObiPbIwSqItmOCQYw0LwlDr3GlKJXD2EXk4nVGJ+C86kyZSWj+8tqIizOPy/vPwAwQdkL/4LTkHLVt6Qr/E2ThPHB86Nv8fuKkXdesB9Ty4aDYAxcDqo/m+UOAlh+/MMN6AwxKEZX4/2A3EPxMZFvvoISiJC0/kI/UNLJYMb8FxvNt8GX65z9UkuhwiJbnBLKlGxFrsmvafvA2vKOCrISl5yHjKO/zy8YxsZuDtzyWJ4RqPvcPN360p/tLfNq6nIoNfJ7bBOF+6XLi9TnbuCxYxjyX6+8XQhI54y27XWuUD2+I7+5wJ40pNSN3AKQ46ZSUKPGt2FNoAe/+2M9OfxZQCluQMgN7UCz2hci/LMrWFb/C9ubYHOih5N6lHxxLk3qgRDGvyLqtgscFpZjo+B8xPbD7OHlJlPxIR8uZF7PfNzjnOh5Si9ysmgqtYhUXcmKZWheUrZq3HuIra9J75ZOws/oF5puVqN+wAVkKuf+089UPAFHY+nEMY5RCOHrdh7KWDg/biaIN5RUuKwqN58N2vduZx3d67CBJ8xbwGt+50MFsZbt7AiJtr1x+X9BB4IvBVj4n1Hj8UNeIVYjCGjgdgYVCwYRSTkZBLiF+VMKFE1dzRE96W5wjrE1rR4Rm2h6VuhnQE0aCJO+p2ZRele1XL1hmmfcOMsCaiiD3jxb5xR6pfDWFDuV+b9qeMnPysCu+9G23jvlay4vENbPjvz/cfkfP6hR6etQ6QuWjFr8079ML9zYiPOweWn8sEJFBWLPxVM4VpiO4ucpBK0CkddtlBCGj4riEhDQwlqhyh7lCe05kTM+zCtNVmF0/wKzMrtHEevBPVOXnVOaGIi2nGJSnq8/0QOc+6DsLZdjkIizkFJjOmb0c3Uy52iqJKJDs1QCMknefxrR8+fcEuYgWQ0qYUU7f9uCnTg2l9JnHKxaQvRHroLz9J6GxGqyBNOx0ytM9Vhp4T945NJtVorjnhl64NLWNVV4g64KBqmnr8l6CxTCsR+Oz5lnDjeqXk+8i9byEjDhkVbWp3gCXE2aLJLcDx0YEdEcWHLjVpbZByimQ1poepMg6AD/toBSyreSOg99ZyI4zkrXaOyj8sL/P7Q8Yvv85NUcUTVdYvAL1El5qFWCinmmbT1Dx5IM1Re1bAhoiBEz+iYHE= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: 84017324-8ba6-4336-cb3c-08d9fe3e693e X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2022 00:23:46.3207 (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: I2EZrY4woEChR/aWtn/9Ij1QD9AMFj9MIm6cy7MIulAVwJs5Z+zSuPkvcEoYM3uE4QBdaZmYw1SN0yVxxKob/xqHPuiDlODHSTWFN0oZhbg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YQXPR01MB3701 X-Proofpoint-GUID: 0HAQZu69JuhfUsg3ryaKJ8IMNv4L5nh4 X-Proofpoint-ORIG-GUID: 0HAQZu69JuhfUsg3ryaKJ8IMNv4L5nh4 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 clxscore=1015 suspectscore=0 bulkscore=0 phishscore=0 mlxlogscore=999 lowpriorityscore=0 mlxscore=0 impostorscore=0 spamscore=0 malwarescore=0 priorityscore=1501 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203040121 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.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 00:23:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12770132 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E76CC433F5 for ; Sat, 5 Mar 2022 00:24:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229962AbiCEAZD (ORCPT ); Fri, 4 Mar 2022 19:25:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229835AbiCEAZB (ORCPT ); Fri, 4 Mar 2022 19:25:01 -0500 Received: from mx0d-0054df01.pphosted.com (mx0d-0054df01.pphosted.com [67.231.150.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F23CF7EA04 for ; Fri, 4 Mar 2022 16:24:12 -0800 (PST) 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 224NrapK009166; Fri, 4 Mar 2022 19:23:49 -0500 Received: from can01-to1-obe.outbound.protection.outlook.com (mail-to1can01lp2050.outbound.protection.outlook.com [104.47.61.50]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3ek4hy8phe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Mar 2022 19:23:49 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DMb8m+ij5mW3dujYX7qzcCJji8G8YYxar19GqlDPpJvR/si7yr4bh4ReiR0vpJiiM+hrCaDXyjce6YEc1XSUbPHsntHk/Mr/BXkejyegQDbv2luLJ6UtRR93LkkcdXWEikHanzyrGcvpfV+KscadOT8PzTDktr72/Y3WUr/Cpub482RCKR/Z7ak7Y+aTexnVH7YtJYuBy8x6oQyPp8OY70xyoEb+gvWI5vY2nyI0Zx4aPBkoEl3d2o1dpNa5QqyHeydEByIhT1x2B6asTHTuz/xTuh7SVwLeTkGXqLklZRS8Mdnu2BImd0KOEAMR5jaOmPiLChcNs4EZT3i/jz6N/A== 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=NTOD8kQ71hqgy8sbsqiSElIml6OJR09XR+uhG2mPuDzc+O9yAPxdNmfr5D+fDz4QGtIgSs/71LlRjcYl2+c4p+N7xuM+eToV7jX00FzUSwZWI9zaAx4KLcT6dJ/B+37MA/aKgvUBId7/QUbUsKwJufYGXaC3Gaoi5JUpv7Z9zbkShmpg45n3lHuEWmfKB53u0eO9RtoaXmS4NHu09fwKeYebSygdxYxqeusczqUBJ8gu/YjkB2FU8a9IkrPfGjL4+x1AvioCzlnlxBS94d0Cyke0NkZ4A39fwWQxIiez9VZgr7NQ3Ems1+QZ5S3zPpRF+e0DVLH/tm1WD0Of+HlZjw== 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=ar02D1vZfntbBVXTbsbQYvNmsZWqqAYTXH6yTl4K/zXOo9s1MtcXkbAjU+x+R9Ff3T2W+Au/rneyqx2h+DOU8wCC9Ym+BY14IAHYFDARYXHsIqALqdBKR03SerBFWCym7hqd5ASZXAzmkIrizxyVOnkBLPtR/Jht2emjj5Ls49o= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) by YQXPR01MB3701.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c00:4f::19) 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 00:23:48 +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 00:23:48 +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 v2 6/7] net: axienet: reduce default RX interrupt threshold to 1 Date: Fri, 4 Mar 2022 18:23:04 -0600 Message-Id: <20220305002305.1710462-7-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220305002305.1710462-1-robert.hancock@calian.com> References: <20220305002305.1710462-1-robert.hancock@calian.com> X-ClientProxiedBy: MWHPR1401CA0011.namprd14.prod.outlook.com (2603:10b6:301:4b::21) 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: 02724da5-8119-40c4-b332-08d9fe3e6a80 X-MS-TrafficTypeDiagnostic: YQXPR01MB3701: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: ktUvj4vvU2eQQPElOY6sNei7iy1+RZeKIPT0ZHnCtOQvJnlyxMPPHaazDDLlW1Ev/2VhUs+HTjw41VKfyXJVgPLtYkpepUeYaMaa7qjSuUficRicPXy+woQ9mZH1MjqZ6s/K1M4oj7G7Vxzz0Lc/iykw2DmtkJRCaOaeg9OWBCDDxOM7NazJuvC2LDyinIMB0YEzcyFszggTPgBQ5vb48N2XY1C1CzxVkuRddeGOZDXLVeqFv23o4GHyDWY2XtHdGPfFp3ZT4xIo/ScGipo2JrHpfIgR6soJH5s2RkuDp7oCE7UwDQVZ/cLfpHXikcQNAp8y7z3+fWJTSTKOq9rqiQiaUjKyqhpfhdnnfl37r4rlyd02XFqwUezX/C9axUSNtCxlHpaJ2KTLgW12RRLnrqPbMJ2DU2FnDatv9xRAUmwQjblBzifUgunkTOGIUfsMp2gKD0PCX2n+ZpyVNXQR/zIQ76KM1rdU8lv+ZeIQZhmlcD3IIg6g9+F3rCPUf1cygssbyOoQ/waOzNkQBHenZb72JM8EAYd2PCT3v1Xtw7Cbd4XsNNxFQLOnuRFvi3htUiF3lfRheCv1OJUpNoOQN9GyYL7rvA4SWC38nfX+qoM0Q56SidGHboDMb+qaw2t6h4LICgeanozeMWuFeGG8wWJrfYGCgARiXQZlUny55leWJhJPVhwBfRKjN/1YqESw+bv7Ujnu2j41ZDan5T+2qg== 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)(6486002)(2616005)(6512007)(5660300002)(52116002)(44832011)(6506007)(6916009)(2906002)(83380400001)(186003)(26005)(107886003)(8936002)(36756003)(1076003)(316002)(6666004)(38350700002)(38100700002)(66946007)(66556008)(508600001)(8676002)(66476007)(4326008)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XgGvkSxdR3iVSt5qzPwB1VY6HOOY/cBc1g250BJlTNs4XXXHgI351CH0VOfDxW9irWsyuyFz0emX18RTBh5h2Ii6uENgBSqXcZucbCZwwDAtgNalCM33TSoWeCMSsAyNKj77yj9DzurZ2Rc+8Vd12YzP/uutYg21MVu/ohDaAc+KeD456tkX6hDKKDpzzhHk5VKeZflxpsZXbmKKmY6RP6l8DeGf2Lsm56cixAQdmnLlQ4050GFGUkX75ihTqMdSv0L9PTB40FyzezbcU8lEYzvslq5xl6SHTRUuLpQfQgbhrkY67ycu10rDEAdtR5mR1G9c9IYII6yku6xiUpOB3e8TCUXD48x3YOuKi/rN1fLbgdayFOqFOI+fxiS6cCBzFRupzvEjmAiD++0g5E5U8fphs92Z+9CjBrzWgfOMFwDXG5JNI2kNBqRc8ZtIXHqmIX/zb4+4kk2aXJJuVeIXrX11c34gV9cdBUeH/7VOc5+g/eeFBx2DB2blFp3wGTZ/tm5nKbCA6gwHZ5exb4y8d7EkPmPGTp7TQGNX01J8q++U58GyfEamogDSFD4hMN0kBw8MyuG/7Sx+RtUWA6DFTpBzyjvz+ULiYXe0Lr16W2g90W43UxvaBWBY9NKvXuVNxYnSU+pR5E6If52gYzfI08p3aIY6I7t2106VswkOlIl91BSjvBA/Y4nmHuitGjVd34bERSjVuSTYs8i4xFCMGs5sT+UruT5oS0q3nXFgdwzlSfLbIcIFLMMZV3PrPcDN2aFhWCiWCcAw6SFpv6bNTVMr6QRA/JIQt8JsKLDXJEtEAB46qvnhCWamthU51PSZiI6/vEOyGo5wSRFYQrIqF/Wake9T2gCkrEN+j9St5vPg1GMrWd1UN4n/NwNrOVTZgYAd7CTKclddlafIOBykxp7DGypN+vNR1wmVZNYnGizEhkELNET1VxmpJCP//4aqinnbkNBGtgfxxCwpjCTWeZtEqqfzXlxD6BX/d189GSQB5+LgKoPbdSSO4h+7Yo9c9mzqTeSFzkOHuLYCqSTT9XfnJc4ESUwp1D89yQLO3O+32jM4sdXzrwGQkdsCfpvlXahzQs5c/faUTK2oPVvfyzCBgnXxkZEPIJZFFHObfL7Hsm79yxC0edeB4LMI5j09bw+eKBeIfbQ5DszgwuVXMT6XuWV2pMnR1hMj+lqReMovJjJVEsTqX/3UZZKFb9095R39Gnt2k20apgYX4gUaMR50hQ5dP2xLsQ6/xTJzQTve86KY4VJAfCIQY2wjvoRnH6OayDnan44wurKOhZKVP1r1cXiHvasafZdWhNdM5Hiba5idL0nzMnITU3WuwQQpXjVIW5nxC4sVVpLt5hcZuVkKJuH4rv8bBizydUSLORiJqoy6dqVxJ9stSzhdo2l3KQUJuZ1+b/pn4eibQkC4Hmg1T8p81we2ZGTrJQ7ZHM7d8sftMvaM7XjrQchZfKNPvUyPN5LB8FEDuGZJeKMfghGmTb7Oz5nzlbOqeHkJimBgRMfbFMeZ1Kh/aQx+sRPAv0Q0qsnfrUCRWq14bHFK1wrDfE7n179fzIiN8pUv7cZhZHlUOORYql3lJam00EGPv8PKCZXLgUSlDeHTF6U+c3NnTxue9hogGVwlafFAiYaW7tUvHC6yRMnZmrwYSRzsO23ihUzunIYKJeSqWGiCy7mu2FT0yvJDdHmRwDHA/ZM= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: 02724da5-8119-40c4-b332-08d9fe3e6a80 X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2022 00:23:48.1019 (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: b8O4QC0N+y2EelJUMWP4uTv04sjG9jxiAT1L5cfFrQxOXcc4yH6UnEhRizn+xR0xYZIaNGVu17TykejHJskMECnv8EakKIEEuU4PuCXI5do= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YQXPR01MB3701 X-Proofpoint-ORIG-GUID: HgoZzkMB6sU-6VLqlEyRDrmWXU22_CZw X-Proofpoint-GUID: HgoZzkMB6sU-6VLqlEyRDrmWXU22_CZw 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=6 lowpriorityscore=0 bulkscore=0 mlxscore=6 malwarescore=0 impostorscore=0 clxscore=1015 priorityscore=1501 adultscore=0 mlxlogscore=123 phishscore=0 suspectscore=0 spamscore=6 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203040121 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.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 00:23:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12770135 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E90FC433F5 for ; Sat, 5 Mar 2022 00:24:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230197AbiCEAZJ (ORCPT ); Fri, 4 Mar 2022 19:25:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230186AbiCEAZD (ORCPT ); Fri, 4 Mar 2022 19:25:03 -0500 Received: from mx0d-0054df01.pphosted.com (mx0d-0054df01.pphosted.com [67.231.150.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3569972E4 for ; Fri, 4 Mar 2022 16:24:14 -0800 (PST) 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 224Me5vf015540; Fri, 4 Mar 2022 19:23:51 -0500 Received: from can01-to1-obe.outbound.protection.outlook.com (mail-to1can01lp2053.outbound.protection.outlook.com [104.47.61.53]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3ek4hy8phf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Mar 2022 19:23:51 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TIt/Vo5GMWH7OD2ZYDfdubvuBPa1YPIzLbmc2eeVtPD2snDlph+uUPPuZG3/38AXUxy3sWYtFbw7izDTpaBoQchyoILGhjJlinlZO9DwUrNTptrVpMOH/HOa0ED8K4a19logcB980cdEZ90Ww9IZ6pwiG10nBtBQHbi1BXz8ehVU+iIUYgyKZFq1NKWtnHT7GCwbMjDYlIuwZPpufT9Bc8Nq24xZDSxwab1KB3/jgSlvTGl/jm5Y+qxKP7u0C0U8gp1wpuef3sElIeZWrBddoh8S13bMa35MtuzaWsEmmLumrPof+IAdFO2Ju01tuJ4bSKHnp2gRwtyvO3YN4Mcv5A== 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=eN8cO9YJBuntVYjR4BtMhDOZmxyTXlShRcSun4tunGI=; b=Bzc7DbaSnMU43vbWOeXW9cGdsgSYR+u6Rc83x7RKCWY6DJjX/S560UAP4e3UnEuq3rA0vr1adWSHZB24QDNrdQlhxD+QfgXE+Vay07rNQ6grJSb5uaI8+0NBrgocD3R6nVbjqWl0xc9UEOhnUb7vt+Z+mq6uiPyT6jNGnKq9/xEWTeklQN6d/U8IlAQaXmgTvWvNH4qXpGuThOeEauzeXevQMiJQMxBDei2RbLmEsZ6fhcMzBSLPgNObANgXbnc0uSS9wCwbkp/xH4291j4gHASRiDYGKkHDXa/PJH2kYOM7rHpUvuOZo3I5twkLqPvcwWGzuuYzTwJOo1jiCMnq7w== 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=eN8cO9YJBuntVYjR4BtMhDOZmxyTXlShRcSun4tunGI=; b=4nO6/qnnpLgeIf8zExCgHn/A5u9CnhqYZ/WPS5gfGgg77UBUN4sYBtazMDxg2i56r+O74IDLd5w40EU5auWCHXVejlVKJ8Sxf60q8psPmyxXPTQRMjLMhMSyQsyN/snYbn4nP/qO85AeRurbtGwDa+2yG0qs+OlbbHOReG8qxqY= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) by YQXPR01MB3701.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c00:4f::19) 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 00:23:50 +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 00:23:50 +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 v2 7/7] net: axienet: add coalesce timer ethtool configuration Date: Fri, 4 Mar 2022 18:23:05 -0600 Message-Id: <20220305002305.1710462-8-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220305002305.1710462-1-robert.hancock@calian.com> References: <20220305002305.1710462-1-robert.hancock@calian.com> X-ClientProxiedBy: MWHPR1401CA0011.namprd14.prod.outlook.com (2603:10b6:301:4b::21) 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: 7199997e-3bdc-428c-8d17-08d9fe3e6b9c X-MS-TrafficTypeDiagnostic: YQXPR01MB3701: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: w3t4AJDuLsvxj2ZEBh71XkHg83BwtgRTy9iqeC3FGHEQsqRj+uy7VBUr9FKpmckS+ccIYOnnvt0u7L2BQUpsKutFH8EkkBuYYJUKLkny+mqWCOfr8AImiSYn3Y9+XtFvSdOx6NJ1Pw90SGdRBc/iCmNaFBrPTtudQrQtSjVmSM6pnNcFPEZ6M/6mrzcEf122SVG96pFcrY/ABo3CW4IQ/bJZBlA6VyUw0G14k+u4EeK+ww4DwiXoQpx3RdN/GOH6WqFjASYeGTMlsSLGK47egeEaY5T+YKWEPuT8motM5NJ6Dde9Hrg2utUG9q+T+hyts9Yw8CrbWhRGDOxELDadEguCZkiUqCGMKhDKxcQxNaD80LkvQozTgoAUKEqe4oQJ5aKYin2fT2lPr0nZ5w/KokdZ17UA53e7z3vHa+5zZGo/Er2FKSsn5c3i81lBxOamtH8CtzDoUHQXnKgKryOH2O+r3ce6kCwvC4ddfA61zwV63Tv4fJ8oNx+fVFb7MZ+f9cXxy8Kyo57bAPf0PVfQns7RR0eUMfu+U7NnAXXwZm66tGE67LeqKI9UHe7iH2/Fwg3vPKuk0ukhKtEn4znjk/3hMtUfySUGjEOMqM4eCjkp1MfaiJbpH6Ph1EPxFJqKAqphzq2Pj0ciHP+AsC5mx3dzF7FzSAFslzxszCPqVK1x7aAPVRX63X2m3IyAyaIJjNiniWTj9VmKqsQSDmyEWA== 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)(6486002)(2616005)(6512007)(5660300002)(52116002)(44832011)(6506007)(6916009)(2906002)(83380400001)(186003)(26005)(107886003)(8936002)(36756003)(1076003)(316002)(6666004)(38350700002)(38100700002)(66946007)(66556008)(508600001)(8676002)(66476007)(4326008)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: a1FZaIIneD0FyyR0oUDT2AHx+eg0dIgPK2zGaHidjjpacLt/Q0yWD1NXpI8vxpz0GiFk74lQITl6loeklvVSRiGJAnBIU8Uclr/iIeFy0Oy5TWpPwOIXsnEs8oVog5g1wYfYgZAg5dt1g6Z2cR3uY8FIJ2vNBDXmyMDDXPxZ7m1Qjv5pfE34+eEtEFJxEu/tMeOPxZNSODrlxOpzyuFVaCJXkY93Y2Uogn7i6tKWKWyKFfDOwJkHJPqxx/hE9LQvSiywsYJ4KLn4CmPXo7KI5MXInqmaIP9DzrQFU19FKDd0nRGKrdlb+uq/rO/lImxc3Nq+MMevE99VN/DMydVJFVm0hja9ta6gKOgBBrLWYwaPxErGN1GBW3UeyiaV475P6VYhaOOug9b7D6m6PZN+zWHhNaiZ1HAPCaHgmgkPqq+sh7r60ukfLD/KPYgFkiOTZNI/KmDbncfIPurOvzK8UKdEgV5Vi7OOrPTtbzVErGSY3/J4+57LCqkh5TG4LuBTZgTHO65ztJuhlNT3T0LyCVnKlLXDUFEX1yDxk0tczR+wRSVI889YNLNV72V/1uSF6IlkaVYFkpv6BL8fNkfS/2f7OM7qWOYky9IzRaKEOuTDoEGtGvCE4SrrPFlgatvcOwaA5ZhgwH2+G26I/PyojLAuH5OQvghpJUq/FIiNerQE26WockOPpyZ5vOYd43TOBjJwn4oZAHMe9F8MOiktbcCwZp+05ULLRpyzb69IvBleXR6EZKPMSjVv5Irn+idTTaguOrk4lpjCUic8y5JT/i5DsepWRPm7JS/1FSNUP7ouRXSJ9DxMfvCZEUZpqYPNgzCQ+m949TtmiNNihjd/isIyHhE7cBKGM4Bio2BidOo7V+4pV98RowqTaMZjmynPUS6lQNGxtdxyD0dVL1baKwMVz3OgQIxIOZ0e/j7PCw0dLzVVcDuTQr7pr7F6fXv3lkWgpRHmWpgatW2i/KicIfMoFE8w6+YExb+vKR816SX7bnHdkU65nbkIIOe0ZpAvrcZet/OE7JK5w3B63ahpoKO4s09xhLZFLoGFXKJwwe53vVLp+2EEKXlSF8qEUMvfphYr1hAAK8BTP7o8UuXbWSr8lvs+e2hWAFfG6WPfh46UQeqbSHe5SvChNvGIm+MFNhzX0efzrLdyAc9/VxLF8HF0bH+R+RvXQCVlZddYa4gcVPlzX5IHLSmVmHpyKkdT38qKCtGRziDEcReQFxwRx3hhlZQtJ5YMShheHGnB/1HPpXdJ1u7sdXU4donvb/fP19RAsHTIYmNYjcln70HbyDtFvvqY9Z5zldiOYqLVx94Vc66owsxUzrplQtox02PYtZWaLfN4VU7qk870tS+yfU+RKpgCukemm1/GvBzKqDZQm08AL/DtVoq79SzJSovAt68HBWbZDrlFXYqE4WlLwX4JFzwDWvRmFGQVrVWEq6cAoQkvz9ntj81EotJEKQx83eEXa/JO7qiPzFxZxqkWyVoLkqS7WVkLpptqrLYFccG6wCct5EBeavVOoZcnC2lqjz6NIgiDNgDX4Z85KlWLDCEsJm5ugEsiVCOv+9G5ughYaoVz68CE6oDkVK6z6HqoIri0IRA0MY/ln7dxKh/1/GDRXSLVQ9ZuS7YTFfYO+cJvgo1/j7SQPT3ywqUJ2ubUfzhsAjwugOUjFG0qHBgHYw/c4sX62JvlC2sZmgKVfPU= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7199997e-3bdc-428c-8d17-08d9fe3e6b9c X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2022 00:23:50.3527 (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: 1WYXy3fdTRaz2h7fYmMejnKVPKUFMQlx61IFv1qWjPuSCKdf+3Hb2ImFGL/qeP7hmATh6krMHN7yk21NjOwFky/5RjN2oY8z2/kmCW5nmgk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YQXPR01MB3701 X-Proofpoint-ORIG-GUID: Q8gE4z-P62aINXHFWJV6lV0cdiV38mq5 X-Proofpoint-GUID: Q8gE4z-P62aINXHFWJV6lV0cdiV38mq5 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-2203040121 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.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 | 8 +-- .../net/ethernet/xilinx/xilinx_axienet_main.c | 51 +++++++++++++++---- 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/ethernet/xilinx/xilinx_axienet.h index 6f0f13b4fb1a..f6d365cb57de 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 */ @@ -482,7 +482,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);