Re: [PATCH] spi: spidev: only use up TX/RX bounce buffer space when needed

From: Mark Brown
Date: Fri Feb 13 2015 - 23:50:23 EST

On Thu, Feb 12, 2015 at 12:13:08PM +0000, Ian Abbott wrote:
> Devices have separate, pre-allocated TX and RX bounce buffers of fixed
> size. Currently, each transfer uses up space in both buffers even if
> the user-supplied no TX data or no RX space. Change it to only use up
> space in the TX and RX bounce buffers as required.

This is a bit hard to parse. I think you're talking about buffers in
spidev here but it's unclear and you've not described in what way you're
changing the code and we do currently only seem to copy data when the
user has asked for it.

> Since dummy transfers with no user-supplied TX data and no user-supplied
> RX space will no longer use up space in the bounce buffers, limit the
> overall SPI message length to INT_MAX instead of the buffer size.

That doesn't seem to follow at all. No mention has been made of
eliminating the buffers entirely or otherwise ensuring that we can
handle transfers of any length - not using the buffer for transmit isn't
going to make the receive buffer any bigger and indeed...

> if (u_tmp->rx_buf) {
> + rx_total += k_tmp->len;
> + if (rx_total > bufsiz) {
> + status = -EMSGSIZE;
> + goto done;
> + }

...we do still seem to be limited to the buffer size here as one would

Basically I'm not entirely clear what this change is supposed to be
doing or what the expected benefit is. I *think* the goal is to allow
multi-transfer messages with a mix of unidirectional transfers to be
larger but the changelog needs to be clearer and it's not 100% clear why
we'd bother to check for INT_MAX.

Attachment: signature.asc
Description: Digital signature