From: Arpith Alexander <arpith99@gmail.com>
To: Mark Brown <broonie@kernel.org>,
Lixu Zhang <lixu.zhang@intel.com>,
Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Weibin Liu <liuwb@xiaopeng.com>,
linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
Arpith Alexander <arpith99@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH] spi: ljca: Don't require data in write replies
Date: Tue, 3 Nov 2026 18:44:35 +0530 [thread overview]
Message-ID: <20261103131435.21838-1-arpith99@gmail.com> (raw)
Commit 0fe4573c822c ("spi: ljca: validate the response length before
copying the data") made ljca_spi_read_write() reject any response whose
payload, as announced by r_packet->len, is not contained in the data
received.
That is right for reads, but the adapter acknowledges a write with only
the packet header: r_packet->len holds the number of bytes written and
no payload follows. The reply is 2 bytes long, so
"ret < sizeof(*r_packet) + r_packet->len" is true and every write fails
with -EIO.
Where the Intel Visual Sensing Controller (IVSC) is connected through
the LJCA, as on the Dell XPS 13 9340, its initialisation fails and the
camera behind it is lost:
spi_ljca usb_ljca.ljca-spi.0: transfer failed len: 256
vsc-tp spi-INTC10D0:00: SPI transfer failed: -5
intel_vsc intel_vsc: error -ENODEV: init hw failed
Only require the payload to be present when there is a receive buffer
to copy it into. Write acks are still checked for a non-zero length that
does not exceed the request.
Fixes: 0fe4573c822c ("spi: ljca: validate the response length before copying the data")
Cc: stable@vger.kernel.org # 6.8+
Signed-off-by: Arpith Alexander <arpith99@gmail.com>
---
Tested on a Dell XPS 13 9340: with this applied the IVSC initialises
again and the camera works.
0fe4573c822c is tagged for stable but has not been backported yet, so
it would be good to get this in before it is.
drivers/spi/spi-ljca.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-ljca.c b/drivers/spi/spi-ljca.c
index 8fd001610f67..b1babd43adda 100644
--- a/drivers/spi/spi-ljca.c
+++ b/drivers/spi/spi-ljca.c
@@ -109,8 +109,9 @@ static int ljca_spi_read_write(struct ljca_spi_dev *ljca_spi, const u8 *w_data,
if (ret < sizeof(*r_packet))
return -EIO;
- if (!r_packet->len || ret < sizeof(*r_packet) + r_packet->len ||
- r_packet->len > len)
+ /* write acks carry no payload */
+ if (!r_packet->len || r_packet->len > len ||
+ (r_data && ret < sizeof(*r_packet) + r_packet->len))
return -EIO;
if (r_data)
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.55.0
reply other threads:[~2026-11-03 13:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261103131435.21838-1-arpith99@gmail.com \
--to=arpith99@gmail.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=liuwb@xiaopeng.com \
--cc=lixu.zhang@intel.com \
--cc=sakari.ailus@linux.intel.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®