spi: ljca: Don't require data in write replies
PATCH 1/1 spi: ljca: Don't require data in write replies
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.
---
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(-)
drivers/spi/spi-ljca.c +3 -2
@@ -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
Signature · 1 line
2.55.0
Hi Arpith,
Thanks for catching and fixing this. I missed that write replies only contain the header, with no payload following.
The fix looks good to me. For stable, it should be backported together with 0fe4573c822c.
Hi Arpith,
Quoted 7 lines · Arpith Alexander
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_ljcausb_ljca.ljca-spi.0: transfer failed len: 256 vsc-tp spi-INTC10D0:00: SPI transfer failed: -5intel_vscintel_vsc: error-ENODEV: init hw failed
Indeed. I can also confirm this is the case on Dell XPS 9315. I guess it's the same on all systems with LJCA.
Mark: can we get this in as a fix for v7.4?
Signature · 3 lines
Regards, Sakari Ailus
Mark Brown
maintainerQuoted 1 line · Arpith Alexander
spi: ljca: Don't require data in write replies
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.4
Thanks!
[1/1] spi: ljca: Don't require data in write replies
https://git.kernel.org/broonie/spi/c/5072a9fae45a
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark