From patchwork Mon Apr 10 19:55:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shenwei Wang X-Patchwork-Id: 672261 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 F1ADBC76196 for ; Mon, 10 Apr 2023 19:56:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229701AbjDJT4S (ORCPT ); Mon, 10 Apr 2023 15:56:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229693AbjDJT4R (ORCPT ); Mon, 10 Apr 2023 15:56:17 -0400 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2088.outbound.protection.outlook.com [40.107.105.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D939E73 for ; Mon, 10 Apr 2023 12:56:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U+P/L+fupj7Y2QIks7735sdwYtTtPg4eHhQjQp2oJMhrNYu+B91sN0zcXfEVOmuKntxyTSekhzJrjJWj4t+i3RRdO/Nim9B4N4ypjzumEj9sTTVsZe563mnCPM6jP78tdY6M6Kw8M6/sUXbwOy4a4cxfGIjkVINB2AR6sR1D+P1UfzI3c6H0RpUrV+airRMTo9TPkk8J420EMXvZ9ALSK11c03F9ZlZwphCWTUTrCNdX7T7Gw1za03ogxiMjoYzCbtsMzG2iQ5vSoBfZ3C+JMJhv3Pa7+9xZkZ9FzWuOTeJ5Pp19RazkyqsYUcf+6w9Ehj5BnDb9rHvN7/HlISoRMQ== 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=5qZsysnO77TeqFgBApIGGVaChr3GVGs9G4IIH3JON6I=; b=liuFo9VOFZ0SirriwvsqFZroMrDc2tPBV2prwypgDXtFMEQSGnKV9+Sj4gQZqZWxoPEqAVOmiP7M6o58a8BKOAYK/05Fdai5It4nIB9ADr7fn6Sby5g9OkB4GGON/MjGNSdhkAdEY8/SaTj24fh0LYdPcd6VlGmvxJ5FnGGHvo9HrssFukd5dLN2Rp8s4nMbvU8Cb4MFmazK2g1+xryRIBPC96+YFo4AcILLzvzWJA6glamcQ813BJaG29HZiCFFGGmHVkMkIxgSd4lRZZE/EM6THb4EhXYg3eVLpDthCwSljUXTUNZMotEkWqK2jUt9mAtzjozes/mLoIHEdNffCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5qZsysnO77TeqFgBApIGGVaChr3GVGs9G4IIH3JON6I=; b=SvWu+LARh26++qjkH7ZipScyo8dn+qcw/kB3TU/4ovRa0qW6eA9ZMgY6AYnwqL9ljZl4Acd5edxfjx7ZG7Wt1829Lin/xY4f7B8VJ9eorEz9XXM1Qk16qNolPgz/2Hp6JcU5U2oxBsGALlI/ZhktoHH3xRJMVEs+DYJrXIVxf9Q= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9185.eurprd04.prod.outlook.com (2603:10a6:102:231::11) by VI1PR04MB9884.eurprd04.prod.outlook.com (2603:10a6:800:1d0::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.36; Mon, 10 Apr 2023 19:56:10 +0000 Received: from PAXPR04MB9185.eurprd04.prod.outlook.com ([fe80::28fb:82ec:7a6:62f3]) by PAXPR04MB9185.eurprd04.prod.outlook.com ([fe80::28fb:82ec:7a6:62f3%3]) with mapi id 15.20.6277.036; Mon, 10 Apr 2023 19:56:10 +0000 From: Shenwei Wang To: Greg Kroah-Hartman Cc: Jiri Slaby , Bhuvanchandra DV , linux-serial@vger.kernel.org, imx@lists.linux.dev, Shenwei Wang Subject: [PATCH 1/1] tty: serial: fsl_lpuart: adjust buffer length to the intended size Date: Mon, 10 Apr 2023 14:55:55 -0500 Message-Id: <20230410195555.1003900-1-shenwei.wang@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: BY3PR03CA0030.namprd03.prod.outlook.com (2603:10b6:a03:39a::35) To PAXPR04MB9185.eurprd04.prod.outlook.com (2603:10a6:102:231::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9185:EE_|VI1PR04MB9884:EE_ X-MS-Office365-Filtering-Correlation-Id: 42eeb9b5-d31d-4d4b-f00b-08db39fda147 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XZ7V16miS5f1ckY+KVYhL+B2RnW3NRWX4vnd0C0m9RNtHNBuhyM8N+tFww0CEd7Jgcl/hFh5SPvwoZCa5od/5GKFGVAws4nI3YfxHf4TCzF5eLo63gLeQO6idqeLhHucWMBSDKQVIQ8jJ5GEs67DOlbpvQAC+fT4mODXPPZ6rFa1JqvQhg0Wu2sJpVZ31UHhXKEhk7sVsW0rTiYtzf2c57oO2bL6uyrCLvN+EB6+K2I4qEEq4fvSItxcDGpL58kGGWFPrb87F41YAB3ia9s2wbvnTxjNl2lBkfXSw67EMWuj+o/uVxFXMggDROPyB8ds8+fD2DbO/am9zNgNZbZLT1TFExjNcrhnQGnViu++zOVLS1cqaAhZMEmyFdh7fonhTBk8ZkckbKXAoqvwkFY+RdBmw+V9FKsKSbBsA/GAo3FPJgBJ8WcZ2ZqjCHoMPOOIPqC584mayx4pMUjOksev9muo0lnfFnQvr3wC/RUxQzt7jtn3ou3jjmvsklYlE+3KDd4HMSls93JwuzWjMXXCUhMDIMdYe6KrmcS5BDKrBXFM380X9waocsgskjD0JRoqdWFHtnYzQ54EUndl+o7UUiYLwo942pqtDIxBcO+PYLh058HS+667MXx8ttgpG9bf X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB9185.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(396003)(346002)(366004)(376002)(136003)(451199021)(36756003)(86362001)(4744005)(2906002)(2616005)(6666004)(6486002)(52116002)(55236004)(83380400001)(186003)(6506007)(1076003)(6512007)(26005)(66476007)(6916009)(66946007)(478600001)(66556008)(4326008)(41300700001)(38100700002)(8936002)(8676002)(38350700002)(54906003)(316002)(5660300002)(44832011); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: W9LWM8PhKd02aibQanyd1i6wWFRfU3X2E8LSlcgSwsS7gUjTPPAlPuBgWyzt8us9MuopCK+CgbQIbPk348WFoYJDAy8Y9AX6ybfw8lxyvtzUtoJXIqOe2pgov02lRy4pfinuJyCqNvrpYBiWp0KfMIiquoMXhIXKA536hgPgRFiTlUG9uwe29OkAMswpkwU/WER6duU3vWAuUOr4mMxBfBmBg1fxcwW3AQ0dBRtwChx56OHMK/cYO976KsKajhJfdpPHL5FMpRrtaOEmT+WBnTcnCfwOcYogor/1BsRsuMekHT3UL4MmupZ/QZuw9jGnYbI2QB0SowJL0f456EHViOh6LF9GhX6BHgV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jbbHoXwAwGKJOpBcA9gYsZTvLpQafWtb4TXAh8OK/uf6P5oudJ0SSQ5F62Q+ikffVxBIFCzNfie1uKmSz2MsuNV1tkpw9bzR+ZotOKphdj9AuwKgrp8YGmXhGQAsyoU2zF2e9AW+/t8eqaGBUpPxojmCGoeIv8CdHN X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 42eeb9b5-d31d-4d4b-f00b-08db39fda147 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9185.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2023 19:56:09.9894 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HlVrwG9hbsTGqtD++EvJX5oApB/VHbbSMfv/vJi4CiDA9P60gDQTDMsU1qrQbXgrxG6rLu/X2pxj3c1satvSfA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9884 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Based on the fls function definition provided below, we should not subtract 1 to obtain the correct buffer length: fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. Fixes: 5887ad43ee02 ("tty: serial: fsl_lpuart: Use cyclic DMA for Rx") Signed-off-by: Shenwei Wang --- drivers/tty/serial/fsl_lpuart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index 074bfed57fc9..aef9be3e73c1 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -1296,7 +1296,7 @@ static inline int lpuart_start_rx_dma(struct lpuart_port *sport) * 10ms at any baud rate. */ sport->rx_dma_rng_buf_len = (DMA_RX_TIMEOUT * baud / bits / 1000) * 2; - sport->rx_dma_rng_buf_len = (1 << (fls(sport->rx_dma_rng_buf_len) - 1)); + sport->rx_dma_rng_buf_len = (1 << fls(sport->rx_dma_rng_buf_len)); if (sport->rx_dma_rng_buf_len < 16) sport->rx_dma_rng_buf_len = 16;