From patchwork Sat Dec 9 22:23:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bigler X-Patchwork-Id: 176250 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp6263602vqy; Sat, 9 Dec 2023 14:28:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IENTm+Bi1Yc883A4beDItSC5prwAGG/HSl23/zFn4+7IkUYOexmRTQhZrhS8Gkwv/Jaxq68 X-Received: by 2002:a05:6808:14c9:b0:3b8:bb80:b36c with SMTP id f9-20020a05680814c900b003b8bb80b36cmr3278752oiw.30.1702160881042; Sat, 09 Dec 2023 14:28:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702160881; cv=none; d=google.com; s=arc-20160816; b=nHMRZdOANksvKa5f4A3SOJKyFTq1F/dzLIl4wQyO96MHa6GgSS0nRCeAZPBX3znG2N KPI6HriNKB/Qg2cOEkW0rR5NleFr2lWJ35eWupzwEw+fRDdDPzcpSBCpR/wxh6+bKupL 9FlEDpSOt8CDBOO3gTfWNPKOaKV8P0shP0NPwwD5WaCneBW11gF3O1IhbuW8zrVCSzxb b/uFMKedYNBZsP0yjwS5OIhL+Qub9pZ10Dcx9OzypJIIh7S9YolZ3WICmAO+eRBdhb2N 7TdhGLSiJaLt1nch7AKBi2CJ4N1YOFeumiUmyJSco+9ZMigIohSkDmL3Z4hcQrkI2KPp 4GCQ== 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 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id kp12-20020a056a00464c00b006ce45456a0esi3677631pfb.46.2023.12.09.14.28.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 14:28:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; 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 23.128.96.38 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 4C77180785FD; Sat, 9 Dec 2023 14:27:58 -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 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:27:58 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784845047860056392 X-GMAIL-MSGID: 1784845047860056392 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 */