From patchwork Sun Jun 4 14:23:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liming Sun X-Patchwork-Id: 1790102 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=U0LFbHjJ; 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 4QYzWX6zDDz20Tb for ; Mon, 5 Jun 2023 00:24:08 +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 1q5oeJ-0001dY-0O; Sun, 04 Jun 2023 14:24:03 +0000 Received: from mail-mw2nam04on2043.outbound.protection.outlook.com ([40.107.101.43] helo=NAM04-MW2-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 1q5oeG-0001ay-83 for kernel-team@lists.ubuntu.com; Sun, 04 Jun 2023 14:24:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eseZBsZ3hqgdOyvbZ4tdFrd4Eiik9e/YY9ze/C/uqhRzAO80v5f+urcelhpf7yBpkVs7CcT3aXaNReyORf/WU1KUSLEYq8JqvPoXTwKX956R00iEy6sdZn3U3J7yao6oaILTux56V7337Ly9ksRTeAjQvqXk3S/J0IZjaNWTxS1kuedLtCErFD87mjziezLOYITSi/+G02m9oQT30hyvJihoat7bpMl7oysM11IEt+jpRHB4M6JeXCRHlsWY0nN07JegfECUsnUyOkVAcdAMD619BcnPlC3nYlhbzEFZd3o2q4ik96g+PpvoCeQx5OyQBUDNJYnOrWLqSXii1wdwKw== 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=utVXAQHlfeeUReudj+WTc8/0VekhgBU5h6HSycjp+WA=; b=hHaxOBVP17oGyMZZMuFc1h+4WVlygeHk2vze50WWEBJd40Mp0vT/5VAhZbTbfmOkqthj/45Zqh3UximyIKO7vIip6uW8Hi2r9dTNiNNgxYF8f2uDDonssVxckB4CQ8k2UwxJMv6ZPhproEdDpEnyCpYeTakmeBAtjW6m39D6btEaeOgJT4voPixA3QucAkmQCZwxJDjl0+HX4d8gljrjBXlB6+7b19uEiuhNu2EAZLooakuBULGIIRYCHzcuC3X9fi8m7yvZAQAACHSkQvp+z+asPlfih3ZO/0BBa4aTY7NZVHdDrOTRIWLWjPHhREsgwKy4t7fCqEpHDbtkByvUYQ== 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=utVXAQHlfeeUReudj+WTc8/0VekhgBU5h6HSycjp+WA=; b=U0LFbHjJFT8S3SbXRzsnGA53RZlJiG+6thyXCSrWDu1Rt9etAxNgUi5IEseh9izkgxOd/IejFUqwr/OA5QhMb/9eks0Lwn5PLKxzCzDImYEPq9XzfNrJ1Mr0l99mAZiGGOrgq/9ggfo/oU8KAZPqZgcwd9TbP/4lhVNjcxk7Jmswdji87joJIrghxkgrTuRc9qdshjhuv2ytIHsu0zWDp33qMgUpCZ/1pSTkB1pyYBt+tK6tXYY4Toe01hS7ZWcYjkcI67KaTW/30xVOr5nfpcNDXUHpDLy2sFq7TAQ5lVIuSu7amMa6YBAgdytX0kZ7tSp8mH35+0z/ln3V4wlXpg== Received: from DM6PR02CA0109.namprd02.prod.outlook.com (2603:10b6:5:1b4::11) by MW3PR12MB4489.namprd12.prod.outlook.com (2603:10b6:303:5e::8) 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 14:23:54 +0000 Received: from DM6NAM11FT016.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1b4:cafe::6a) by DM6PR02CA0109.outlook.office365.com (2603:10b6:5:1b4::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32 via Frontend Transport; Sun, 4 Jun 2023 14:23:54 +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 DM6NAM11FT016.mail.protection.outlook.com (10.13.173.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32 via Frontend Transport; Sun, 4 Jun 2023 14:23:53 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) 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 07:23:35 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail203.nvidia.com (10.129.68.9) 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 07:23:34 -0700 Received: from vdi.nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Sun, 4 Jun 2023 07:23:34 -0700 From: Liming Sun To: Subject: [PATCH 1/2] [SRU][J:linux-bluefield][PATCH v1 1/2] UBUNTU: SAUCE: mlxbf-tmfifo: Drop the Rx packet if no more descriptors Date: Sun, 4 Jun 2023 10:23:05 -0400 Message-ID: <20230604142306.151526-2-limings@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <0c5d1413dec7019a2ad8520920e8fcbef8ed72f2.1685455239.git.limings@nvidia.com> References: <0c5d1413dec7019a2ad8520920e8fcbef8ed72f2.1685455239.git.limings@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT016:EE_|MW3PR12MB4489:EE_ X-MS-Office365-Filtering-Correlation-Id: 13757461-9ef2-4f8a-870d-08db6507535b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZJgQ5Y7a6xeUmaNlBtE3odQgnuzENuqrExMjygiFyPqXPubs6NWvjou+yWIAdqmFSMOEG2w3O/cr1ZLgD9lI8KD3DLK2nNKPY89GA11URFpHzrNtPsF+OGvELQeGbRsP56QUmCn6+AGIvumTP08U29+SFKXjZb7nuhDNj06e9Z/zLo/q3icliSiKsaFnWvAIyuMe/WQAXjRyetOd1ZFg0Mofubp/tABf51B3kJTqjxRaZoy89pAvRI+FPm99TxrzPHy1LFxioQRRcatjG7z9uKmkNxQUVfbDEpReOxsNBtvzyNusq2QLgacGUEijjsbImdorxWV6ZqPAYZ+PTlNd6DuZ1ZluC7PSepYA4gYdGRqhqpzQ+iNeX33h9fZVN0CbCF0k/RwduzqcaYe49O1LErmLE1jeZSRRBTlQz91M8UYtpyW0pnEFgzKGzI+M3FVvRJga10wVT6lD4mfbRPkluS1SCnN+W6q0FavDRKIN7762NjBIQJtHe36nRyYikfIjEk8hyPeUteIjIcTc9uXVvckeSzCCPfHmVbqTeGbza7/thnD8nA0V1/wmxFkZTWNZmtm0Mw4tIQl0FZAXea/bk5wVS1RxkQ/BtlpiSKpE0JroCqsmU0HWNLA9ohHQmGsALNsEukULiiQqYcqj44CNle+Fbp3KgdAdYQT/p1d9LdpHEbfPNhckFmJGF2igqE7S34PATj3Tgf7Y8P4Bq9QalzH4ZCvEzLzfEAfJBnPMuA1+YPm+W1DmTzQ7mRC+f7mYAWciM75EQrsWwuhQ0olI31/ZDR3bQ/bqlmTUc3L3MC9oaj3aiDoRIYfqeCAOlv9F 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)(396003)(136003)(39860400002)(346002)(376002)(451199021)(46966006)(40470700004)(36840700001)(40460700003)(478600001)(40480700001)(5660300002)(8936002)(8676002)(36756003)(2906002)(86362001)(82310400005)(4326008)(6916009)(70206006)(70586007)(316002)(7636003)(356005)(82740400003)(41300700001)(2616005)(107886003)(1076003)(26005)(36860700001)(186003)(47076005)(966005)(83380400001)(7696005)(6666004)(336012)(426003)(29513003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2023 14:23:53.9334 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 13757461-9ef2-4f8a-870d-08db6507535b 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: DM6NAM11FT016.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4489 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 --- v1->v2: small update to set 'vring->pkt_len = 0;' v1: Initial version --- Change-Id: I98c2b9aa2e21277675022775538f053df393da4e --- drivers/platform/mellanox/mlxbf-tmfifo.c | 65 +++++++++++++++++------- 1 file changed, 46 insertions(+), 19 deletions(-) diff --git a/drivers/platform/mellanox/mlxbf-tmfifo.c b/drivers/platform/mellanox/mlxbf-tmfifo.c index 19d539fc99ae..88610f45456b 100644 --- a/drivers/platform/mellanox/mlxbf-tmfifo.c +++ b/drivers/platform/mellanox/mlxbf-tmfifo.c @@ -59,6 +59,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 @@ -75,6 +76,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; @@ -86,6 +88,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, @@ -275,6 +282,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); @@ -380,7 +388,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; @@ -508,8 +516,6 @@ static int mlxbf_tmfifo_get_rx_avail(struct mlxbf_tmfifo *fifo) return FIELD_GET(MLXBF_TMFIFO_RX_STS__COUNT_MASK, sts); } - - /* Get the number of available words in the TmFifo for sending. */ static int mlxbf_tmfifo_get_tx_avail(struct mlxbf_tmfifo *fifo, int vdev_id) { @@ -732,19 +738,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; } @@ -847,8 +859,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; } @@ -881,17 +901,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 @@ -1073,7 +1100,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;