* [PATCH] spi: ljca: Do not wait for an ack after every write chunk
@ 2026-11-25 13:49 Paul Menzel
0 siblings, 0 replies; only message in thread
From: Paul Menzel @ 2026-11-25 13:49 UTC (permalink / raw)
To: Mark Brown, linux-spi, Lixu Zhang, Sakari Ailus
Cc: Paul Menzel, Hans de Goede, linux-kernel
The LJCA adapter in the Dell XPS 9315 (8086:0b63) is a USB Full Speed
device with 64-byte bulk endpoints, so ljca_spi_transfer() splits each
SPI transfer into chunks of 58 bytes, and ljca_transfer() waits for the
adapter’s ack after each of them. On the Full Speed bus, every such
round trip takes about 0.3 ms.
This is most visible when mei_vsc boots the Intel Visual Sensing
Controller (IVSC): it downloads about 1.7 MB of firmware with write-only
SPI transfers, which takes about 12 seconds. Tracing `modprobe mei_vsc`
with the function_graph tracer:
SPI device statistics: 1730864 bytes in 3407 transfers
ljca_send(): 30085 calls, median 279 us, 11.1 s in total
usb_bulk_msg() (OUT): median 133 us, 4.6 s in total
waiting for the ack: median 146 us, 6.5 s in total
Only request an ack for the last chunk of a write, and send the others
with ljca_transfer_noack(). Bulk messages arrive in order, so the
transfer still completes only after the adapter has handled all chunks.
A write chunk then takes 112 us (median) instead of 279 us. Reads and
full-duplex transfers are unchanged, as each of their chunks returns
data.
On the Dell XPS 9315, with Debian’s 7.3.5 kernel and only spi-ljca.ko
rebuilt with this change, `modprobe mei_vsc` (mei_vsc blacklisted, so
that the IVSC is in its reset state), two boots each:
without this change: 12.28 s, 12.08 s
with this change: 7.56 s, 7.34 s
Both cases transfer the same 1730864 bytes in 3407 transfers, the IVSC
boots, the IPU6 finds the sensor, and libcamera captures frames.
Sending several of the 64-byte messages in one bulk transfer was slower
(8.4 to 8.6 s for 8 messages), as the adapter seems to NAK the next
packet while it still forwards the previous chunk over SPI.
---
Notes:
The analysis (function_graph traces, the A/B boots), the patch and this
commit message were drafted with claude-opus-5-5 (Claude Code), asked to
speed up the IVSC firmware download, see
Documentation/process/generated-content.rst.
Only one LJCA firmware was tested, the one in the Dell XPS 9315 (BIOS
1.26.0). It honours the missing ack request for SPI writes. If other
LJCA firmware versions still acked such messages, the late acks would
complete the wait for the final chunk early. Lixu, Sakari, can you
confirm the behaviour for the other adapter firmware versions?
The hardware test used the v7.3.4 spi-ljca.c, which equals the one in
origin/master 4dce97c6c2655 and linux-next 3dd8c790a7b70, with
the same condition; this exact commit is compile-tested (W=1) only.
drivers/spi/spi-ljca.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/spi/spi-ljca.c b/drivers/spi/spi-ljca.c
index b1babd43adda1..37050d0b01bde 100644
--- a/drivers/spi/spi-ljca.c
+++ b/drivers/spi/spi-ljca.c
@@ -100,6 +100,17 @@ static int ljca_spi_read_write(struct ljca_spi_dev *ljca_spi, const u8 *w_data,
memcpy(w_packet->data, w_data, len);
}
+ /*
+ * Each acked chunk is a USB round trip of about 0.3 ms on the Full
+ * Speed adapter. Request an ack only for the last chunk of a write;
+ * the bulk messages arrive in order, so the transfer still ends only
+ * after the adapter has handled all chunks.
+ */
+ if (cmd == LJCA_SPI_WRITE && !complete)
+ return ljca_transfer_noack(ljca_spi->ljca, cmd, (u8 *)w_packet,
+ struct_size(w_packet, data,
+ w_packet->len));
+
ret = ljca_transfer(ljca_spi->ljca, cmd, (u8 *)w_packet,
struct_size(w_packet, data, w_packet->len),
(u8 *)r_packet, LJCA_SPI_BUF_SIZE);
--
2.54.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-25 13:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 13:49 [PATCH] spi: ljca: Do not wait for an ack after every write chunk Paul Menzel
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®