Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3163509rdb; Sat, 9 Dec 2023 14:28:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IE7AXWTHEGYPGXy6krM8yf/O2s7fsDjsVPFGCxAzWTgYa7jPbQiHhFo7nW8KxSkxDF0XsY8 X-Received: by 2002:a05:6808:f91:b0:3b9:e2a0:16ac with SMTP id o17-20020a0568080f9100b003b9e2a016acmr2862992oiw.80.1702160885242; Sat, 09 Dec 2023 14:28:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702160885; cv=none; d=google.com; s=arc-20160816; b=Zq2ujYgak3a/s4dpoXzxC+umiDsZDXRQTQz/k9DciEwNCwRPP9rOZMfPhfXUZV5oqX CtPAlJhEdYp31VxMztBXL+nCm8RY+03hoTw6SW1Zn8P4snS/Pe2zjusemoM/VCcWUjd9 lQ8KvEqo2JBanVClew1GNLh34EO2xyg3GXf8Mjnkpq7Ylr2u+AQFEn179ya/Nu0LTk4u m9sodV7PnbuMYlio/1sccyUh93PO4EqvlJaxwz9yPRfDyGOyOpKTQ/vn8sDt+lIzkRqj SKclW1B9Bnoyvvc3Bjofo04S9jITSYUc2FuMgqEvWsVlK1Ig3eV/sEta5sz0m/IeIk9r xsXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=t8ELKc1Cx3E8L/yzeltsw12gNVTCfffQeRQ2Wh6HnwQ=; fh=qNJpwS8KJAtxhvz5Sd7w8WvK6h7RA4qFyOtdY77kMkY=; b=ekjKtDll+hufdvCio6eTgwIUFX4MdRX1JlLhDkNAX8Adv00EqixL9yvYel03jdnZYF wvVrWks5CGysqFepyMsDw4spc9NPO98vrbIurrtHysRG4r7CTGbnBy6J+hJIWtuzWc2N 24c3yFdblKJGoJeTe3PiSiDpP86UEHWz3s1yYWrMJL/l0bk1kx4OMaeP463cSs4cTnw6 woPuHp2RzmlC4EtW0FhYeBvkCBDsNneiIDI+NtvZ5z7X5HU4fAfVp6nqeduO4OstgXSn ILHilf8jazXt06zecKprS1mfnm9koyyFrVBp8byUbN5TZYMb/QbiBXHGY6KhrmAFEAf9 e2AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bigler.one header.s=key2 header.b=CHbH0zOO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id d14-20020a170902cece00b001d1db5e39adsi3784211plg.95.2023.12.09.14.28.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 14:28:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@bigler.one header.s=key2 header.b=CHbH0zOO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 8ACCB80785FD; Sat, 9 Dec 2023 14:28:02 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229518AbjLIWXy (ORCPT + 99 others); Sat, 9 Dec 2023 17:23:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbjLIWXx (ORCPT ); Sat, 9 Dec 2023 17:23:53 -0500 Received: from relay.yourmailgateway.de (relay.yourmailgateway.de [188.68.63.102]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCF02100; Sat, 9 Dec 2023 14:23:57 -0800 (PST) Received: from mors-relay-2502.netcup.net (localhost [127.0.0.1]) by mors-relay-2502.netcup.net (Postfix) with ESMTPS id 4SnjGM0tLjz5y97; Sat, 9 Dec 2023 23:23:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bigler.one; s=key2; t=1702160635; bh=EnxGptbbemOBXJZfV7Vdg0y/0R3Tx3smsS3ArovZmIc=; h=From:To:Cc:Subject:Date:From; b=CHbH0zOOz3Jf/cajxDDY8a82K0BvdDEZxgs/z32F5zJagT9BKqJ5q9eKNfvTVUahJ MvgUu92rSoEnnNXgqUFjGOob9w4b9y1ql3qfZf5skgARZ5u2M0kKO0qGIgR1JdZk8j gGSs6UcCXwXOQ9e0SJyjlLW/sPhFmRpCMd1Dudva5CUT2bRRG4BFfXLqt/xtaHTH4p AryC/cneGyx6131ryZMiSd/KUhv/l82zl3qjBnSx9UmB22SYRupqqaFjbMy85ck8V5 4sihq8TZGDKSY6anR6JzRKBA1/4k7GkNJYQ6m8Ws2RdXwCcmkPlOn8aDnJ/Au1Muke unYqCcpDbwAeA== Received: from policy02-mors.netcup.net (unknown [46.38.225.35]) by mors-relay-2502.netcup.net (Postfix) with ESMTPS id 4SnjGM07lwz4xR4; Sat, 9 Dec 2023 23:23:55 +0100 (CET) Received: from mx2fc6.netcup.net (unknown [10.243.12.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by policy02-mors.netcup.net (Postfix) with ESMTPS id 4SnjGL3rqdz8sZh; Sat, 9 Dec 2023 23:23:54 +0100 (CET) Received: from bgi-desktop.yallo.box (xdsl-188-155-37-14.adslplus.ch [188.155.37.14]) by mx2fc6.netcup.net (Postfix) with ESMTPA id 5391B40949; Sat, 9 Dec 2023 23:23:49 +0100 (CET) Authentication-Results: mx2fc6; spf=pass (sender IP is 188.155.37.14) smtp.mailfrom=benjamin@bigler.one smtp.helo=bgi-desktop.yallo.box Received-SPF: pass (mx2fc6: connection is authenticated) From: Benjamin Bigler To: broonie@kernel.org, linux@bigler.io, francesco@dolcini.it, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, regressions@lists.linux.dev, stefan.moring@technolution.nl, regressions@leemhuis.info Cc: Benjamin Bigler Subject: [PATCH] spi: spi-imx: correctly configure burst length when using dma Date: Sat, 9 Dec 2023 23:23:26 +0100 Message-ID: <20231209222338.5564-1-benjamin@bigler.one> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-PPP-Message-ID: <170216062984.32454.7026503541350922205@mx2fc6.netcup.net> X-Rspamd-Queue-Id: 5391B40949 X-Rspamd-Server: rspamd-worker-8404 X-NC-CID: 13HCmpbDjgbCAcX7po9IGUoUBO+mApUJNZfnb4TkhsINTgs= X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sat, 09 Dec 2023 14:28:02 -0800 (PST) If DMA is used, burst length should be set to the bus width of the DMA. Otherwise, the SPI hardware will transmit/receive one word per DMA request. Since this issue affects both transmission and reception, it cannot be detected with a loopback test. Replace magic numbers 512 and 0xfff with MX51_ECSPI_CTRL_MAX_BURST. Signed-off-by: Benjamin Bigler Reported-by Stefan Bigler Fixes: 15a6af94a277 ("spi: Increase imx51 ecspi burst length based on transfer length") Link: https://lore.kernel.org/r/8a415902c751cdbb4b20ce76569216ed@mail.infomaniak.com --- drivers/spi/spi-imx.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 498e35c8db2c..272bc871a848 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -659,11 +659,18 @@ static int mx51_ecspi_prepare_transfer(struct spi_imx_data *spi_imx, ctrl |= (spi_imx->target_burst * 8 - 1) << MX51_ECSPI_CTRL_BL_OFFSET; else { - if (spi_imx->count >= 512) - ctrl |= 0xFFF << MX51_ECSPI_CTRL_BL_OFFSET; - else - ctrl |= (spi_imx->count * spi_imx->bits_per_word - 1) + if (spi_imx->usedma) { + ctrl |= (spi_imx->bits_per_word * + spi_imx_bytes_per_word(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) + << MX51_ECSPI_CTRL_BL_OFFSET; + else + ctrl |= (spi_imx->count * spi_imx->bits_per_word - 1) + << MX51_ECSPI_CTRL_BL_OFFSET; + } } /* set clock speed */ -- 2.43.0