From patchwork Sun Feb 4 09:19:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Song X-Patchwork-Id: 196470 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp264919dyb; Sun, 4 Feb 2024 01:13:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IEkM3jxiQo9bnvGDZF55IyOeA5VBhnfbCa0SsAaTDb419K3enBvKwqONwAGlwABoA4NqjBr X-Received: by 2002:a05:622a:68ce:b0:42c:837:ecad with SMTP id ic14-20020a05622a68ce00b0042c0837ecadmr2757983qtb.47.1707037983145; Sun, 04 Feb 2024 01:13:03 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVpum5ODSItalKXmasUsLaWmjEtDsZzFwH1ZeCKW8T8YL/hlT559KvFpNtfOJae2FWrd8+22tBex8AVUcBoZfr4V+Eitg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id l17-20020a05622a051100b0042bfd4add67si5914522qtx.724.2024.02.04.01.13.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 01:13:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51548-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=ApAApiVt; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-51548-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51548-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DC50A1C20C0D for ; Sun, 4 Feb 2024 09:13:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A2307168DE; Sun, 4 Feb 2024 09:12:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="ApAApiVt" Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2073.outbound.protection.outlook.com [40.107.7.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3271D16429; Sun, 4 Feb 2024 09:12:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.7.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707037966; cv=fail; b=Q5/BZgvHMh37lDPlfAGsEYO84Pn/dA3gfPs0qfiVREWE40HEzPAZEGVG38CCt1daPVQlE15iI48vvsSEm7gPvBDGC698Xqq0xD/JXCMeyl0wy0gEud69V4RRenBcLsdswOBanuDPBVWOtrDpMAUgHJg/yaoTzxd0ffEPsPNh9rU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707037966; c=relaxed/simple; bh=xpsZUrBXASqGb4J22WBF/8vDsdJ3Qpn6Wau8hSLkZGE=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=RPgWFXf59lvsibDaUyZzEUkWZ3sOoFPamI3T0q201UMdEVE+i8RUb8KA1aDOu7GaiwUfMOzQNTqvSCBVHAqnelKfqt8iOuHTDUNCEzY8nfpAWKFYjlnkcwPBfJMZYnPBGtA/+8HzMVMGXPdFejGZQMGHMDdTAaq6ZxdOGpyCtJ8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=ApAApiVt; arc=fail smtp.client-ip=40.107.7.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c3ftYj2xsT/ZQwuSVLEHTyzDg+nTsvPJRTcboHvGxc1EEcCpCqYsgrN9JlVlynujv3SLElqUVXZfz3KWxVbBD3kfVvoxjKoTAdHLLWWOsDabjMcoGklTh9iFbJ5RG8wCMzKw/sqVMdkNqUerHyNHBhLJc77l4BmX7KJ9nYrpK07+Gt11KJQ8W0cQx3uZyCx24ia2Pt2lfxTM1tFCoKl2eOvuH7zKNwWI7FrsY72oNczlDuGpoBkCph4Ovm8ZLr6wxZliNsRan2kIMUjKuFxrM+svPgVJpRQN+OkbDjhj32IJZw+EvWuGQsCj3MfeDILLfemzSmni0aInIEzdXbZj7A== 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=fv1NHMGHU3tkzFJw3595hRiIGM+Nw3hDHnY1ofg10qA=; b=bTSZffNbvW0V6k9S3jLrNRXDSXsprt5pFKV4p2boYKMPTupTVw7JRWi3G4qWXoEIm1576Esjf6FfobS7NGw37ifSRP8NiCJ+snstScjxWP0Iwi5CQN8VPE6KnKsfEVHSKgCa4mQJ2HSUCUaEQGA6MjZ00GjH3ColEoQzyXWFIBp38hCr7Kwqgh+tqr1gxggF3KIzTIGljSoAt/eMmRLP45VCpub915jdZbcylCPCSdrkNmTwXw8FUQEvfZBFA+Dmqanoy+7WOzIRCVQ2P1xj9vk6G+vUSnQEEcCZOcLytTa08Wdcoe4VnyGpetFC4FKgUpFlmly7Ybkvhy6syR78lA== 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=fv1NHMGHU3tkzFJw3595hRiIGM+Nw3hDHnY1ofg10qA=; b=ApAApiVtBj8xzu/c397D92L3UhUDdvgz9szUrw+6HVqBmD5oQUdoQz0Fk/iQJBt79wBsYI0sfibv6WYpjB9hiMI6UNbPQW1SBeXcDzQUAP5tk0QYwURQ+CULPjX6ph+fwusa99CmeKuo3iSIHe98fiyQVUx7lVuDtWxdl6s+cmI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB7PR04MB5003.eurprd04.prod.outlook.com (2603:10a6:10:1a::19) by AM9PR04MB8922.eurprd04.prod.outlook.com (2603:10a6:20b:409::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.33; Sun, 4 Feb 2024 09:12:41 +0000 Received: from DB7PR04MB5003.eurprd04.prod.outlook.com ([fe80::6bca:3978:83bb:8a8a]) by DB7PR04MB5003.eurprd04.prod.outlook.com ([fe80::6bca:3978:83bb:8a8a%7]) with mapi id 15.20.7249.027; Sun, 4 Feb 2024 09:12:41 +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 v5] spi: imx: fix the burst length at DMA mode and CPU mode Date: Sun, 4 Feb 2024 17:19:12 +0800 Message-Id: <20240204091912.36488-1-carlos.song@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: AM0PR02CA0010.eurprd02.prod.outlook.com (2603:10a6:208:3e::23) To DB7PR04MB5003.eurprd04.prod.outlook.com (2603:10a6:10:1a::19) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR04MB5003:EE_|AM9PR04MB8922:EE_ X-MS-Office365-Filtering-Correlation-Id: c34f20c3-3b5a-4e4c-4d51-08dc25617008 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yzSQoIahaX8NeRLfZ2Lu8HaIw0+nx55dZOWR7hZOSESOltNgBzO3p//GUSrY3JvSiJ8dhbvrmO9icHaFLUqktsb9WVJV8PGftwgtZ5Ep2W7ASMXv5Q34sqMY1b6SIbqsKnrnQA2P8EyDhw2Hq6oqxcmYA4bVH0l8KvWeJasRSztdnQvnS+K5xqfIKhhfMbwKyM3Dnd5rh3OkUCF2f+HerNURjWQ0Msanx+Bu3KAMgrN0FowvNrUS/t7Wuz8dOdEAarPBXiBCX+hYKy8L5bs0opgVjRFkPXEaCHSTcPMnVu0c2/72ILFeCirHpR3y3aaNqCz2nDtsYSkKx7BNcNRi27jk7ndEdW6XjZXL4i4ZUJvtD/j9UG6a+XRIU5m0bzTRabVirJ8uEtyY9cI0cMRzgT5C7Uc7b6ML49uTOr8dUCjj3rSlLxLjOoh2muvqdFHLpWV+vxMxvY+iflmZkhJwwvDcN+cAaxnFe0FNtLA4ILMLqfZy8KPoiTxDr6LggrYfxj/+ipOlBYE9rKz0ofCnEU6qED7wlJ4q8NXrgc0HaRuIrodt8JKS7svw+d5iLQ1l+wzoE7PMhKwx2EqqWlfg/dCe3FBFRuO2kAPqOLo0XI67NyOLSLWdfN3Dve0EXTQT X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR04MB5003.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(136003)(39860400002)(366004)(346002)(396003)(230922051799003)(186009)(64100799003)(1800799012)(451199024)(41300700001)(6512007)(52116002)(9686003)(6486002)(478600001)(38350700005)(86362001)(36756003)(2616005)(1076003)(26005)(83380400001)(2906002)(5660300002)(66556008)(66946007)(316002)(66476007)(6666004)(6506007)(38100700002)(8936002)(4326008)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: e3HaowfLCXihh2X6c5iCn7wTN7D6+gYZRmMI8/AqbGGMeUkhyaLC3/ddwcezPHlSK68ww+0VSTTY6zxKUShMsKDT+nRSrfdkrceCIU83wsD9dQW04KpxS5tg0r9rNDDKjBHvDC+vaeSaqoNZmGBNqkDC/pYFCvGqAg6mdoG+uxUGrP/OwC9iIQ/TI2Aw5LFR5M7THZOFGhIDZsvhecsv1aK5oBH+RZWRmnDrxWFwF3Q5ei51aYJkUfuEQTWm/OEr96yaNYE1Ti3VT1Y7nNc6y4e3SBGcm+Y/DMEpF90ZX6iCUl6PGW9U0Abc3H4t8BOJbQZIecuu8jtsr2Rj+hBTR8FjFfbPjRyBI1vuYdaR1K5hEgob3/byRVaUxWn4+C84MLQIQY0i5FWLqwtwEZ0/VtYHw6az3WH9C4G5sQl4yHngjYTirMlyHOV4325puI/asOyGXa/Xr+tDAh3jYIIOQI7Pqikc2fgIAe2k4dKah99Xcev7F/vckTgdAq+RRSXuZm8IVd+49oUA6w+BSvg2qAV6gBGq+BTx3kJmir/2hR1T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-Network-Message-Id: c34f20c3-3b5a-4e4c-4d51-08dc25617008 X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB5003.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2024 09:12:41.1975 (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: 16wYZEUBvz11Z09iTMZXZd0uhUM29p+LMGbk0tIKO1ZfJdZxPY6HTX5zraHSuFCdJIEr+EsNAXImoO8nw6HIpg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8922 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789959060236996084 X-GMAIL-MSGID: 1789959060236996084 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 calculate the total number of words according to spi transfer len and bits per word, burst length should be configured as total data bits. 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") --- Changes for V5: - fix the the method of burst length calculation compatible with non-byte aligned wordsize. --- drivers/spi/spi-imx.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 546cdce525fc..833a1bb7a914 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -2,6 +2,7 @@ // Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. // Copyright (C) 2008 Juergen Beisert +#include #include #include #include @@ -660,15 +661,15 @@ 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 / DIV_ROUND_UP(spi_imx->bits_per_word, + BITS_PER_BYTE) * spi_imx->bits_per_word << MX51_ECSPI_CTRL_BL_OFFSET; } }