* [PATCH] spi: ljca: Don't require data in write replies
@ 2026-11-03 13:14 Arpith Alexander
0 siblings, 0 replies; only message in thread
From: Arpith Alexander @ 2026-11-03 13:14 UTC (permalink / raw)
To: Mark Brown, Lixu Zhang, Sakari Ailus
Cc: Weibin Liu, linux-spi, linux-kernel, Arpith Alexander, stable
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-03 13:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 13:14 [PATCH] spi: ljca: Don't require data in write replies Arpith Alexander
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®