From patchwork Sun Jun 4 13:55:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liming Sun X-Patchwork-Id: 1790097 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=kjQhNFy5; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QYyvN292Kz20Tk for ; Sun, 4 Jun 2023 23:56:14 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1q5oDG-00085w-N3; Sun, 04 Jun 2023 13:56:06 +0000 Received: from mail-bn8nam11on2041.outbound.protection.outlook.com ([40.107.236.41] helo=NAM11-BN8-obe.outbound.protection.outlook.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1q5oDE-00085R-FP for kernel-team@lists.ubuntu.com; Sun, 04 Jun 2023 13:56:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bGk6c/lFRMaRS94P7oR6bx9A2VAaJMmnltHpaHcpPd0vxVPp0Fbm2ERNT6SeP1E43dxjVondXtChpsLHcne2prqx+5i/1IaZgeebgZRb4t/o0dz3xkEP5X0qi7qg0WN7bzGbpniqF7aK58pHzsY83dJ8hD3KGzgP5S2Z1f0OKcJ3fopjYFddtfc5sHsqbDWvuSdrIw/An4VjHpeUIsIwinLBqBv1PVnaxivRjdZqrCDybTgSNor1AScVkVFSeMWjdsq7tuaxHM6bivMW1FDOrlLRSECgXCcDWWCj88leqEjir3kHlJ8/+TwYMC+d6wzm6u9DYqA+uxZWva0Boi94uA== 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=YeaWl42yqt2wxoc+tcnDxouaVqMksOMjm8M4g8S8/Hk=; b=Vd1qLBniCogHTdbN6FQu6M8mW4j/RWjVfG07i2SDArwyGBT40C8ueAEnCYb9Y0nFukNh+GN7zcoI42ASzw5NbMW0t3Fv6l7MJqEvnMMi9dgHqEvLPjFP1TVjwwuOvTrBk74aN/Ijumr6CtyK/P+YChxA6y8BiIgupcic7rQ8xcCmzjDvCHzCwG7OiXMrfPMyZXxPp6u6skMlIbLpMf05QMLJp/9WlFsIu+smBGwKGKtmkzrZQpEn2bcZulb3bEJvLlbeCtx/B4sEsOVX4VbzlwAvKGCS1fTD26Y2fSgcTtDqLF21zNdq+VOQwFTAFKU6OO9T/659SrI66ELEabO1VQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=lists.ubuntu.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YeaWl42yqt2wxoc+tcnDxouaVqMksOMjm8M4g8S8/Hk=; b=kjQhNFy52+Rhm9SxFyvYO53UW4MXSLleVjqJp3JZWVS0TEK3i4Fa7ISg80rZsL1SNLSz8WS/bbz+IFUPxgeXS5Yzd+/H+EpQzBjVbqIKtlEZRNHc0kjvaLf9xC0blvlwg302P1Rm50pkGAn7vJZbClmMRBNA3UUaKmzxg0bqZgmTNgIwSKfO5vBniVWNceHBHm+oqffJbId/RL1VbGNOmwtvhlIOA9tkX0DtfQWEXyBjkqsFi7LkYdS+9gi1ly5/5gwswGWbemjoC0CfB8Jjz2D/wU5IKQVRDioWXDXya5WbmNYv0xr/vqrxUUDByx86cRWW3sCSBz7e/xgIjPF6Xg== Received: from SA9PR13CA0082.namprd13.prod.outlook.com (2603:10b6:806:23::27) by CH3PR12MB8329.namprd12.prod.outlook.com (2603:10b6:610:12e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Sun, 4 Jun 2023 13:56:01 +0000 Received: from SA2PEPF0000150A.namprd04.prod.outlook.com (2603:10b6:806:23:cafe::8c) by SA9PR13CA0082.outlook.office365.com (2603:10b6:806:23::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.18 via Frontend Transport; Sun, 4 Jun 2023 13:56:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SA2PEPF0000150A.mail.protection.outlook.com (10.167.242.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.13 via Frontend Transport; Sun, 4 Jun 2023 13:56:00 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Sun, 4 Jun 2023 06:55:46 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Sun, 4 Jun 2023 06:55:45 -0700 Received: from vdi.nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Sun, 4 Jun 2023 06:55:45 -0700 From: Liming Sun To: Subject: [PATCH v1 1/2] [SRU][F:linux-bluefield][PATCH v1 1/2] UBUNTU: SAUCE: mlxbf-tmfifo: Drop the Rx packet if no more descriptors Date: Sun, 4 Jun 2023 09:55:29 -0400 Message-ID: <210fdf2c9b40f511e0b2e02d5d8bb9ff2bf591f9.1685886644.git.limings@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF0000150A:EE_|CH3PR12MB8329:EE_ X-MS-Office365-Filtering-Correlation-Id: cc1139b6-3b6f-4718-7f11-08db65036e25 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R8O0qo7dpX6O93QlKazyzsl8f46cc4BxUF3e5yholwei1NAeKn46Gwc8jBj0+l9EgBW1Z45cgmwProTfefXbCkWX+8iFu6iDj1UHIRe5j+kTTRG/vn9+/swXU5n5sqZII7mXjtv+/T1vLk3NkkJHUH8lhtW3gNyzQE1PsXnjElM1fxNqchhMn8f5g6XtpLN9wdLuIxtpCaA5hGSd/tcrtxFYQOrUMzZDiC1V3AL3f5C5tqsEuDFUT4++QoWioRz7JSUiG4oDd8Hv212pNEvmwii5xEyQxqNAqHn5U5Zm0sWGQjI9IY83gau6fkNed/jm3tTmWEMvjfyAkHSamp1ZX4Cl/1ZBR61qVrp8tl6IIy7qmPCKmoikE28Y5nswr1GlwPmjk07+9w/XTRL9yoZPQcNnl6rGdjTJDDd0lRi4dIGqiLsZv3OLBSDu6stk4XF/YpxKpkhrRKrtVkp4GcDh07BKZwr2PDJCwqLCF5MXU8X6/iEOAcUd4AP6ol/ToU0aVCbvqCoE8w4dW0IDUXkRHKrlohxfiSsOKzuZAAZDA0GobMM0ov9D+VhZGmZRAUEKKYsqUeJ/l7ZLnM3PHA3869lC5aj9yd59p/uDN1SWnyf50Y7xN2EiOgVS8MZ57SAKYWigrcZq7Vnt5xTeJoc7wVTVRq1uWfJujGykRQs1xsOMjXPUFyfFv4yY4J7DF2J6hGmFyopQIOSmcfwznbEGpwGdFH0XPw1KW5WxyeYGBwAKIop37MJh+I7Q1RaUbtu+n4WCGFYBFF60PnZRs5omsjhUJ9XfbO89V+U/qsKYinXYsCTE3ovONkBLCYwZoqIe X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(136003)(346002)(376002)(396003)(451199021)(46966006)(40470700004)(36840700001)(40460700003)(83380400001)(47076005)(336012)(426003)(2906002)(2616005)(36756003)(86362001)(82310400005)(7636003)(356005)(82740400003)(36860700001)(40480700001)(966005)(7696005)(316002)(41300700001)(6666004)(5660300002)(107886003)(8676002)(8936002)(478600001)(6916009)(4326008)(70206006)(70586007)(26005)(186003)(29513003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2023 13:56:00.8909 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cc1139b6-3b6f-4718-7f11-08db65036e25 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF0000150A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8329 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liming Sun Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/2021749 This commit fixes tmfifo console stuck issue when the virtual networking interface is in down state. In such case, the network Rx descriptors runs out which causes the network packet stays in the tmfifo and couldn't be popped out thus blocking the console packets. The fix is to drop the receiving packet when no more Rx descriptors. Signed-off-by: Liming Sun --- drivers/platform/mellanox/mlxbf-tmfifo.c | 63 +++++++++++++++++------- 1 file changed, 46 insertions(+), 17 deletions(-) diff --git a/drivers/platform/mellanox/mlxbf-tmfifo.c b/drivers/platform/mellanox/mlxbf-tmfifo.c index 38e1c7780e69..9a03823e895a 100644 --- a/drivers/platform/mellanox/mlxbf-tmfifo.c +++ b/drivers/platform/mellanox/mlxbf-tmfifo.c @@ -56,6 +56,7 @@ struct mlxbf_tmfifo; * @vq: pointer to the virtio virtqueue * @desc: current descriptor of the pending packet * @desc_head: head descriptor of the pending packet + * @drop_desc: dummy desc for packet dropping * @cur_len: processed length of the current descriptor * @rem_len: remaining length of the pending packet * @pkt_len: total length of the pending packet @@ -72,6 +73,7 @@ struct mlxbf_tmfifo_vring { struct virtqueue *vq; struct vring_desc *desc; struct vring_desc *desc_head; + struct vring_desc drop_desc; int cur_len; int rem_len; u32 pkt_len; @@ -83,6 +85,11 @@ struct mlxbf_tmfifo_vring { struct mlxbf_tmfifo *fifo; }; +/* Check whether vring is in drop mode. */ +#define IS_VRING_DROP(_r) ({ \ + typeof(_r) (r) = (_r); \ + (r->desc_head == &r->drop_desc ? true : false); }) + /* Interrupt types. */ enum { MLXBF_TM_RX_LWM_IRQ, @@ -260,6 +267,7 @@ static int mlxbf_tmfifo_alloc_vrings(struct mlxbf_tmfifo *fifo, vring->align = SMP_CACHE_BYTES; vring->index = i; vring->vdev_id = tm_vdev->vdev.id.device; + vring->drop_desc.len = 0xffff; dev = &tm_vdev->vdev.dev; size = vring_size(vring->num, vring->align); @@ -365,7 +373,7 @@ static u32 mlxbf_tmfifo_get_pkt_len(struct mlxbf_tmfifo_vring *vring, return len; } -static void mlxbf_tmfifo_release_pending_pkt(struct mlxbf_tmfifo_vring *vring) +static void mlxbf_tmfifo_release_pkt(struct mlxbf_tmfifo_vring *vring) { struct vring_desc *desc_head; u32 len = 0; @@ -715,19 +723,25 @@ static void mlxbf_tmfifo_rxtx_word(struct mlxbf_tmfifo_vring *vring, if (vring->cur_len + sizeof(u64) <= len) { /* The whole word. */ - if (is_rx) - memcpy(addr + vring->cur_len, &data, sizeof(u64)); - else - memcpy(&data, addr + vring->cur_len, sizeof(u64)); + if (!IS_VRING_DROP(vring)) { + if (is_rx) + memcpy(addr + vring->cur_len, &data, + sizeof(u64)); + else + memcpy(&data, addr + vring->cur_len, + sizeof(u64)); + } vring->cur_len += sizeof(u64); } else { /* Leftover bytes. */ - if (is_rx) - memcpy(addr + vring->cur_len, &data, - len - vring->cur_len); - else - memcpy(&data, addr + vring->cur_len, - len - vring->cur_len); + if (!IS_VRING_DROP(vring)) { + if (is_rx) + memcpy(addr + vring->cur_len, &data, + len - vring->cur_len); + else + memcpy(&data, addr + vring->cur_len, + len - vring->cur_len); + } vring->cur_len = len; } @@ -827,8 +841,16 @@ static bool mlxbf_tmfifo_rxtx_one_desc(struct mlxbf_tmfifo_vring *vring, /* Get the descriptor of the next packet. */ if (!vring->desc) { desc = mlxbf_tmfifo_get_next_pkt(vring, is_rx); - if (!desc) - return false; + if (!desc) { + /* Drop next Rx packet to avoid stuck. */ + if (is_rx) { + desc = &vring->drop_desc; + vring->desc_head = desc; + vring->desc = desc; + } else { + return false; + } + } } else { desc = vring->desc; } @@ -861,17 +883,24 @@ static bool mlxbf_tmfifo_rxtx_one_desc(struct mlxbf_tmfifo_vring *vring, vring->rem_len -= len; /* Get the next desc on the chain. */ - if (vring->rem_len > 0 && + if (!IS_VRING_DROP(vring) && vring->rem_len > 0 && (virtio16_to_cpu(vdev, desc->flags) & VRING_DESC_F_NEXT)) { idx = virtio16_to_cpu(vdev, desc->next); desc = &vr->desc[idx]; goto mlxbf_tmfifo_desc_done; } - /* Done and release the pending packet. */ - mlxbf_tmfifo_release_pending_pkt(vring); + /* Done and release the packet. */ desc = NULL; fifo->vring[is_rx] = NULL; + if (!IS_VRING_DROP(vring)) { + mlxbf_tmfifo_release_pkt(vring); + } else { + vring->pkt_len = 0; + vring->desc_head = NULL; + vring->desc = NULL; + return false; + } /* * Make sure the load/store are in order before @@ -1053,7 +1082,7 @@ static void mlxbf_tmfifo_virtio_del_vqs(struct virtio_device *vdev) /* Release the pending packet. */ if (vring->desc) - mlxbf_tmfifo_release_pending_pkt(vring); + mlxbf_tmfifo_release_pkt(vring); vq = vring->vq; if (vq) { vring->vq = NULL;