From nobody Fri Dec 19 20:37:45 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 772D7288525; Fri, 6 Jun 2025 13:37:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749217050; cv=none; b=TaIIo04jA4Kztgp7DTdjwFAL9XSZgJrA4x116TvqNR1uEOWCQ1Kvv3z5i8T/277PADyWACHjDKiESQjSLoIZO9fqM8a/T23cTNjvwJF16ZMs1UD8lslxP1vS/1VEGtq+GAfcEFJ9iAqx5sofMIHZKaBCc7h9o9ieG/gcQhCjLNI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749217050; c=relaxed/simple; bh=tEh4huufuzq1ic95WEsI0KqGy+7qRjXvIMpWGZsEQyE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=seUArZtgcH2Ymz8trb1pQWX+pZQl1ORjlhkkau7KuhuBv2D7PPbhgBk6m0eGhDy4Cs0XGpa0XgGfEe+3sfx+Fhb8PFUO3mcwjYaY+/sJ/Tz46CQ2htUzVUBlscttOimrGJnWBPR0lHSkX3/u50eNE2j49zNRPka8ATyHk0YghPo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PWH0n2xz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PWH0n2xz" Received: by smtp.kernel.org (Postfix) with ESMTPS id 1CAC3C4CEF0; Fri, 6 Jun 2025 13:37:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1749217050; bh=tEh4huufuzq1ic95WEsI0KqGy+7qRjXvIMpWGZsEQyE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=PWH0n2xz5hiZvfDmGlk5sH0M/AJxmbIO2rgvts8/YauCLdHkR6JGLx7rau9pN79QR aklejQSXoN6NOovylhhT+0tdUCdeqdCc5vMASWWSgi/2Sr6NNtT/lmXedmjlT7vuEM 3k/u4NPsZHr/2rz0Bx46lKIWk2t2ZCtIJpto9OOqMidAghE7huFxD/mIKARM5VPv0f oxCLu6pipvLTEUQNCu+L2oB8Su1RhCBrFIT8XyCx4oW5CSIOO7z9q/fBIP7yLBJ41v OQQQxs0r+DOIwX9ji7Ly/PVJf7/HOd+T9Byp9Uztgsv8pR1PtvHNEr104Bar8Z1m3e wO1BsbemPKdpA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D2A5C5AD49; Fri, 6 Jun 2025 13:37:30 +0000 (UTC) From: =?utf-8?q?F=C3=A9lix_Pi=C3=A9dallu_via_B4_Relay?= Date: Fri, 06 Jun 2025 15:37:24 +0200 Subject: [PATCH 1/2] spi: omap2-mcspi: Disable multi mode when CS should be kept asserted after message Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250606-cs_change_fix-v1-1-27191a98a2e5@non.se.com> References: <20250606-cs_change_fix-v1-0-27191a98a2e5@non.se.com> In-Reply-To: <20250606-cs_change_fix-v1-0-27191a98a2e5@non.se.com> To: Mark Brown , Louis Chauvet Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?F=C3=A9lix_Pi=C3=A9dallu?= , pascal.eberhard@se.com X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1749217048; l=1438; i=felix.piedallu@non.se.com; s=20250606; h=from:subject:message-id; bh=JnAoqQPfwv0/3qSqrSpr+Emp+bDl4r2kMZHc5R7JQHQ=; b=8Ly+pvHTwUY2wFGqufeGI2YcF55VFo+rqbUDf1C5kiDONvrNB6+y6N6gl5YdAjDtCD3poym5O Ld5KT/ZUM/yDjrWLG8AjzZEGZcDAHgB3oXXN3oIGQ1wYZiSfUeASf8F X-Developer-Key: i=felix.piedallu@non.se.com; a=ed25519; pk=Xe1dw6DIV7hmFbzuJfvaioG+S30kGix0QpIi5qPg99w= X-Endpoint-Received: by B4 Relay for felix.piedallu@non.se.com/20250606 with auth_id=427 X-Original-From: =?utf-8?q?F=C3=A9lix_Pi=C3=A9dallu?= Reply-To: felix.piedallu@non.se.com From: F=C3=A9lix Pi=C3=A9dallu When the last transfer of a SPI message has the cs_change flag, the CS is k= ept asserted after the message. Multi-mode can't respect this as CS is deasserted by the hardware at the en= d of the message. Disable multi-mode when not applicable to the current message. Fixes: d153ff4056cb ("spi: omap2-mcspi: Add support for MULTI-mode") Signed-off-by: F=C3=A9lix Pi=C3=A9dallu --- drivers/spi/spi-omap2-mcspi.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 532b2e9c31d0d..05766b98de36f 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -1287,9 +1287,15 @@ static int omap2_mcspi_prepare_message(struct spi_co= ntroller *ctlr, mcspi->use_multi_mode =3D false; } =20 - /* Check if transfer asks to change the CS status after the transfer */ - if (!tr->cs_change) - mcspi->use_multi_mode =3D false; + if (list_is_last(&tr->transfer_list, &msg->transfers)) { + /* Check if transfer asks to keep the CS status after the whole message= */ + if (tr->cs_change) + mcspi->use_multi_mode =3D false; + } else { + /* Check if transfer asks to change the CS status after the transfer */ + if (!tr->cs_change) + mcspi->use_multi_mode =3D false; + } =20 /* * If at least one message is not compatible, switch back to single mode --=20 2.43.0 From nobody Fri Dec 19 20:37:45 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 84092288531; Fri, 6 Jun 2025 13:37:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749217050; cv=none; b=XyFKWnV3McynBvCZLRy/xVdu7GK8NZ00WeZSmK+YUWP298UEOZXzxyFzcNp5ltv23+9K7ZsLGmXTsbcNcWcjerrB7G5bCWcphMHoGSlbeNlTY3YvCQ1DVXXtjnaPSQWPjEyA6pjCW39kpQHKfG5I/UUtC9feg2uTI5UXqdJ9NOA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749217050; c=relaxed/simple; bh=j1ZG+UVR+5As58K0nOWtz3Gvux3o3cl7YptKLb923LI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qmKknSxwcHPrm8f3dviazesnTAsno5Ik15QGp8ye4oOB891bKryHK753AsOpI8KlEVqZa5CZLu9GGCZ93mBfv5KL4Vpg0q6z+LtaCGxEigAv3T3imAnmxhjTxetYKM5XezX6ncFbTFiNsi/jIY0S0gUhC0wysC8U/C43NyRTvd4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ATqrxo2S; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ATqrxo2S" Received: by smtp.kernel.org (Postfix) with ESMTPS id 29AE1C4CEF2; Fri, 6 Jun 2025 13:37:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1749217050; bh=j1ZG+UVR+5As58K0nOWtz3Gvux3o3cl7YptKLb923LI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=ATqrxo2SXxWoHPJer9feNq4yP+txY6GY78Ue+4DmtPi+BM158n6kJOpNA8sbDMD28 k0Z4F+f6+n5+BqmR2b03ONdht8F7kovbP3yGlLebrfT2kHeb/uOX/6avJENZ1CUGUa zpydLpYdl31qrNvvgL9jMie7T0f/UTx0aapUzelukchP+KMcWLTh1KNx2dABip88J2 eEDpOBYRNg9Xldog4GDEh3HjcqVU+SujNCNTh/NV40xbrg4EM4/ARqjpGMMCHmDVIP XclNR/bMk9Q1qP/hvbfcB4ztR7SIqvaJCCp6s5l3XHAd/EEMVjL5AF1clcRE3PxmpL 3trmifwV5RyUA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C032C61DB8; Fri, 6 Jun 2025 13:37:30 +0000 (UTC) From: =?utf-8?q?F=C3=A9lix_Pi=C3=A9dallu_via_B4_Relay?= Date: Fri, 06 Jun 2025 15:37:25 +0200 Subject: [PATCH 2/2] spi: omap2-mcspi: Disable multi-mode when the previous message kept CS asserted Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250606-cs_change_fix-v1-2-27191a98a2e5@non.se.com> References: <20250606-cs_change_fix-v1-0-27191a98a2e5@non.se.com> In-Reply-To: <20250606-cs_change_fix-v1-0-27191a98a2e5@non.se.com> To: Mark Brown , Louis Chauvet Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?F=C3=A9lix_Pi=C3=A9dallu?= , pascal.eberhard@se.com X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1749217048; l=2225; i=felix.piedallu@non.se.com; s=20250606; h=from:subject:message-id; bh=ZfK7KhDeQVloCseH0ix7UHPadZvoLWxPnDeBOqVmuHc=; b=zAg37+l7LEpXbrIyD57QaE5LxdWhhzikt5JuQVFnSfTgdNHtR2dlVVo/MIXi+fh9L2k8bNtf+ Csixkf4Oi5rAxvN/O43I2fBIZ7umaEKjlpquA+0lFQttGho9C/QsuWx X-Developer-Key: i=felix.piedallu@non.se.com; a=ed25519; pk=Xe1dw6DIV7hmFbzuJfvaioG+S30kGix0QpIi5qPg99w= X-Endpoint-Received: by B4 Relay for felix.piedallu@non.se.com/20250606 with auth_id=427 X-Original-From: =?utf-8?q?F=C3=A9lix_Pi=C3=A9dallu?= Reply-To: felix.piedallu@non.se.com From: F=C3=A9lix Pi=C3=A9dallu When the last transfer of a SPI message has the cs_change flag, the CS is k= ept asserted after the message. The next message can't use multi-mode because the CS will be briefly deasse= rted before the first transfer. Remove the early exit of the list_for_each_entry because the last transfer actually needs to be always checked. Fixes: d153ff4056cb ("spi: omap2-mcspi: Add support for MULTI-mode") Signed-off-by: F=C3=A9lix Pi=C3=A9dallu --- drivers/spi/spi-omap2-mcspi.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 05766b98de36f..4c5f12b76de6a 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -134,6 +134,7 @@ struct omap2_mcspi { size_t max_xfer_len; u32 ref_clk_hz; bool use_multi_mode; + bool last_msg_kept_cs; }; =20 struct omap2_mcspi_cs { @@ -1269,6 +1270,10 @@ static int omap2_mcspi_prepare_message(struct spi_co= ntroller *ctlr, * multi-mode is applicable. */ mcspi->use_multi_mode =3D true; + + if (mcspi->last_msg_kept_cs) + mcspi->use_multi_mode =3D false; + list_for_each_entry(tr, &msg->transfers, transfer_list) { if (!tr->bits_per_word) bits_per_word =3D msg->spi->bits_per_word; @@ -1289,22 +1294,17 @@ static int omap2_mcspi_prepare_message(struct spi_c= ontroller *ctlr, =20 if (list_is_last(&tr->transfer_list, &msg->transfers)) { /* Check if transfer asks to keep the CS status after the whole message= */ - if (tr->cs_change) + if (tr->cs_change) { mcspi->use_multi_mode =3D false; + mcspi->last_msg_kept_cs =3D true; + } else { + mcspi->last_msg_kept_cs =3D false; + } } else { /* Check if transfer asks to change the CS status after the transfer */ if (!tr->cs_change) mcspi->use_multi_mode =3D false; } - - /* - * If at least one message is not compatible, switch back to single mode - * - * The bits_per_word of certain transfer can be different, but it will h= ave no - * impact on the signal itself. - */ - if (!mcspi->use_multi_mode) - break; } =20 omap2_mcspi_set_mode(ctlr); --=20 2.43.0