From patchwork Wed Jan 31 02:46:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Song X-Patchwork-Id: 13538551 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 49495C47DDB for ; Wed, 31 Jan 2024 02:40:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=v9/+5ipQggPddc7lmOS6bJBsOZSZfeS93s0TCDjK/3w=; b=myhkfHRDh8J24p EIwc7vaot/kaLgZTOkrygxeZCgxH89HPEqnZSWfeUHWT6VtvdxlCzK5Gz8NcC2DmihflfJ+BPe0PM oajtrgHwGOK7mmq6hLQMPf3u1CD8rRd3fZ8KXAf+h9XblSzFm9nHXuh7y8Tt5Pnr19QBiRDO+Cfzi aiNuvReXev87XW7CY+/9bMWXmIN4kW0nVtDMnRt2rnthNIEuYS0XXW886v6DtSkBQ2miqkfBjr6IS pHq3YGguI+zNED6BFvbxkiurU1ZewZzg+WpshGs7AFc7CAIrauV6AMt5owYU8AVAyy8PX6Gy81TAh qJU11pIfULL8kaVeHUqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rV0WJ-00000001IsO-0QKN; Wed, 31 Jan 2024 02:40:11 +0000 Received: from mail-db8eur05on2062b.outbound.protection.outlook.com ([2a01:111:f400:7e1a::62b] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rV0WG-00000001Irl-3j25 for linux-arm-kernel@lists.infradead.org; Wed, 31 Jan 2024 02:40:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F7ecObvEH3GHApKPh25F8Iqf/qAOqPGL4Y6IRKU1a+l7NmHDij7kUmt+3IQ85ROS149BxDr2cl6rtBYCpD7Jk2OPtbkxzT/OwxDvgeB9qmE7ICzJyVGMR3qD2EEbr8XYiQUkQy65n2BSVCrDwHmUZXOsxdGB9v3D9KVvAjpcEBOYz/II60N43GZ0ajMtKalpb6UmzwdpzwQxnXbnn2dsKW4ymuGlO7upyOt5erNT/2otTyTYCbT1nnO+hUl4p8S7IBom7iowGPL6wuhZa85P4OwFEdpEla4MApoewAgX2Djo9mKnQg0T+GdJm5/AslnPXC17bIxCxyY/YVWMhhF6wA== 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=vUnnXqxbCRxxx8DRUxCr8ZqF09IqFIpC2RZMYl+rsiA=; b=c8hoijOI/N+S+NWylaLsMx18JTONsyO2OWzi0EIRB7NJOVw5eEFKoZxMVfBkteIPu1+ixcI61SBfwWqs2s/qzsTTeosh0B9mQLLTDoMU/pesLAgnXil93XZdHH0Ara3q6/9nUYkQe4/2uSDL13FqMkaAL2evq7f22PRRRkkSByG+pQ7FgqHUOzQjINQ0z7hFAHJFS6l0p7JViU1oTRgmobKq7LoCums3JOdJuOnWujwlirtU9atOMIMZSiIBskEmJoTbCuOtClSRBnaxiMuYsLvgPgpcTJmItXd+lEqg56S7DPnSsGNs5iCciUffK9MeVCZpjXsMipEbCEdxu4c/8A== 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=vUnnXqxbCRxxx8DRUxCr8ZqF09IqFIpC2RZMYl+rsiA=; b=WOySVxoMmESw4+18AKGDT1+UmWZ+p7MWVuGgisp/QtvFfFmdJzEFll1Rc6GoTKRPnNDK5Z7oc+/RJ2w+K81VhvOuLzKDiW/n/1CxtmNiuO80qPZRoQ7oCreGK4uQN8SOkSdKx6t0fqBJxAMTqq4p+0wDLhnU2iim2UAGER/B2nQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) by PAXPR04MB8527.eurprd04.prod.outlook.com (2603:10a6:102:20f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.34; Wed, 31 Jan 2024 02:39:57 +0000 Received: from VI1PR04MB5005.eurprd04.prod.outlook.com ([fe80::f702:c85a:d3f2:ffa1]) by VI1PR04MB5005.eurprd04.prod.outlook.com ([fe80::f702:c85a:d3f2:ffa1%4]) with mapi id 15.20.7202.035; Wed, 31 Jan 2024 02:39:57 +0000 From: carlos.song@nxp.com To: broonie@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, linux-imx@nxp.com, benjamin@bigler.one, stefanmoring@gmail.com Cc: linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] spi: imx: fix the burst length at DMA mode and CPU mode Date: Wed, 31 Jan 2024 10:46:23 +0800 Message-Id: <20240131024623.329240-1-carlos.song@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SG2PR04CA0187.apcprd04.prod.outlook.com (2603:1096:4:14::25) To VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5005:EE_|PAXPR04MB8527:EE_ X-MS-Office365-Filtering-Correlation-Id: b695d28a-0f24-4811-b527-08dc2205e990 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X6U+q3g6q3XfcWP/FuDIRJerJ0xw0mRY1sDAfghtfEY01Q+Gq+jgDnB205T9Z+OrlNecfVJ7C8tRLsT+9zwwu/CQg9mzmSSv3GCyn9x6yYEo+RZq2cyXbLik6WSd4j6BrH8oOw07mckJ68RG7Id1PoZf/cKfcgV7WDg8fK9U1lHEQVT/yS38HDsskD3gtDFkhILtYAHKdWSCxhZhQAiCB9LkD6Ue/7E9BnqANIxe1Qhk08w1CEEZOiTPMaSG7+aLam5koxr8SHfv5w5URrqPgaZaXhYFQiK8JCGvJ9lPDnfO97gw99Ni0K6QEzpVBipnco2sJy60VnGzILtRPTPyKxpnmfDCe8DMRohjH/BC9BJbgL3BDp7vJku7AYnAFiJRMKtKp/TzVvBWIc50+wWzJLlBiqWmz9GS9ns6wNQnxjchN69VrHWkNdN8YFDQMy14tmPEnAiKo9f3ETKv7QcL0u/vbedKvQPEJxm6bbIQIkC9xZ+8hcDDjw3Y4cqnh/0d2cWhENzyR5abndnH2InykbyoOEjsBooZ/nKc1Y3AaV8jgjp6rZCwB3YMxdytc708ZB9ULHhNL9jFKN/tcBAwPtY8m/Rev8BaeGfJyo5FLpSLzQRzr3g8mpMGN/+hzmEK X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5005.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(376002)(346002)(39860400002)(136003)(366004)(230922051799003)(186009)(64100799003)(1800799012)(451199024)(8936002)(6486002)(4326008)(5660300002)(316002)(86362001)(8676002)(2906002)(66476007)(66946007)(66556008)(38350700005)(478600001)(36756003)(52116002)(38100700002)(6666004)(6512007)(6506007)(9686003)(41300700001)(83380400001)(26005)(2616005)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zai85eAztl8/OMN9Rpi/SdudsHK4eIgmILxKJM6RisQhQfyUCtRe5/VYhrAZdj/PVvNHkTkeKOaLeLqRAiP2gQCzOPUS3RFhe5d+KXfGiJ+s8FC6iWJf61TQcDbVFTSXjXNVvfTDaEsnBn7dWrDwcQcPu4teAdSygnm4vWYYmDtHjfa3CgKnpiZyGcA/H07mTESSObUSPIcS+zYF6Bx6pfr5XvcaRbboNJtOLGmQEloq2h0diIpPr8GLSAkeBiRuKfj9NbNG1yw6aqh0/sy/ydFGMZuwHVLGwzhDod8U0H9z9O9Ig6KBvCnVr7LYkehfBGaDvt96GEGS8vJ+qDk4hPdCV683lv7N+Odl3630v0VYaSZCq01fUwraEplUuH1J6sUeLmTBPpdB8FNy6EJN6VFmaU/2sjJdarCOUL0S//YIphtXnJD3TzQmxaF4y8VGtSwxRcsCmlR6ZrZE+FaSERY6gtSIgiUkr6sBitiKbZknWxwQqDnar8VfQ5e4T7Fkyu1vbr0lh9s9cgLKZbhHWaMV0NswA/d0e4M+q4L9r7Ub4v5sDn5mBfgI+7CSFd0oc9kw30X/8k0Vo64lV6p6YkBDTUuwfWiqpBAoCMNfr0DWSuzW1LTy+1Tg5uEPcO2hHc+KLm+gP6xcFGPsWlb3fssASO8j9SISZ22Jl+pLHFL8g7RGrKJkZnYuWngFfNa2FK7sUGBcljfdFuDF+VpDxhumcvQX3Wc9Cv0K1GKTiQ8+3OI0BBnOupO9ULcm5uITI4VNQpPkxXIF/mwPdy/yQEnTmeA7gAqvcs2t3/Xj+wGEqQbuW0iFV6LmaXbIC1xz0lWjlA2jPJlcET5Xzg2laJME2fSdRu/X9IVK2YGuyl2/nNmRogdrQJNh2pJWFH14EmnAHRrLMLz3BJlQlWp3flZ7kwiiQ7nBCWu5NHkItczVYpbo/K4Tt3FwGVWY1wXaLerJ12TIfCUjdkOBGDQYYvlRaESMekCUDYlumSS4HS5UlgEjxUFXJhGaYreoUtDcHPILOJSYNK34NpZMv9kTFTKMeqY7gBfFwg8TQAg5N/MwTzrl6oEog7YOb5wfBkl51C4anrZ6ObFxL1AP8G7coW1lB0NGWwCsINDlbX8hWV42bga38GAkjqiqlQ9DxUdhpd0qy9AvpYkan4ZY8d0XDed8BLcFrAkZzRwnYHQ6gYuSR8XyLlDlx5nxciGw2ctxxZS5/vF8H2YkPMp8GyFew7yN+QrAjUipEqLhSDx0qJElxBIedn9p1i9uLLJ0YxQijLcokgkMXcpgu8J5f/XMG+bB8b50Fncq/3lTWJZsXhAvFFabod7M+dwfZ+kamEi3YVB94g3DBqrCTr81leOv3eKt+Jvb5/DPczLYyXrib8WOBJCeT2mwAeH0QQXJKwedmfKPcU5jz5Q4KaV1aAZMx1KjBpittSvHPSOwztqppbTMNGAdOd2iRpy2Eimz1CyL7nvlMI/ZzRQc7zUobZ0zu993gb1o7RWyY1DpBD89mYpxm/3GMede11wCqhowewH0Xcrw+UJvJKnDBOo1RQGQ/mk3tWQAjApd51Q1f9OUHNZkHkfdX+GCCQ2NP3DOSU0x X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b695d28a-0f24-4811-b527-08dc2205e990 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5005.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2024 02:39:57.0786 (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: OrcCP34wVwrtNK+7m83VNxTZgcSVL3sUADGnEbUPZ5+qclf+rHLh31CHutF9U+Pca6Oa8JFUHLA/Xv5M5CP6rQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8527 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240130_184008_989451_2235AE1D X-CRM114-Status: GOOD ( 11.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Carlos Song For DMA mode, the bus width of the DMA is equal to the size of data word, so burst length should be configured as bits per word. For CPU mode, because of the spi transfer len is in byte, so burst length should be configured as bits per byte * spi_imx->count. Signed-off-by: Carlos Song Reviewed-by: Clark Wang Fixes: e9b220aeacf1 ("spi: spi-imx: correctly configure burst length when using dma") Fixes: 5f66db08cbd3 ("spi: imx: Take in account bits per word instead of assuming 8-bits") --- drivers/spi/spi-imx.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 546cdce525fc..b4ade2d53fef 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -54,7 +54,7 @@ MODULE_PARM_DESC(polling_limit_us, #define MX51_ECSPI_CTRL_MAX_BURST 512 /* The maximum bytes that IMX53_ECSPI can transfer in target mode.*/ #define MX53_MAX_TRANSFER_BYTES 512 - +#define BITS_PER_BYTE 8 enum spi_imx_devtype { IMX1_CSPI, IMX21_CSPI, @@ -660,15 +660,14 @@ static int mx51_ecspi_prepare_transfer(struct spi_imx_data *spi_imx, << MX51_ECSPI_CTRL_BL_OFFSET; else { if (spi_imx->usedma) { - ctrl |= (spi_imx->bits_per_word * - spi_imx_bytes_per_word(spi_imx->bits_per_word) - 1) + ctrl |= (spi_imx->bits_per_word - 1) << MX51_ECSPI_CTRL_BL_OFFSET; } else { if (spi_imx->count >= MX51_ECSPI_CTRL_MAX_BURST) - ctrl |= (MX51_ECSPI_CTRL_MAX_BURST - 1) + ctrl |= (MX51_ECSPI_CTRL_MAX_BURST * BITS_PER_BYTE - 1) << MX51_ECSPI_CTRL_BL_OFFSET; else - ctrl |= (spi_imx->count * spi_imx->bits_per_word - 1) + ctrl |= (spi_imx->count * BITS_PER_BYTE - 1) << MX51_ECSPI_CTRL_BL_OFFSET; } }