Re: spi: Provide core support for full duplex devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 18, 2014 at 10:59:09AM +0100, Geert Uytterhoeven wrote:

> For Dual/Quad transfers, which are half-duplex, the buffer pointer for the
> unused direction must be NULL, so the driver knows in which direction to
> transfer. Hence SPI_MASTER_MUST_TX cannot be set for Dual/Quad
> capable SPI master.

This is a particularly thoughtless hardware design it has to be said.

> I'm also worried about the buffer allocation. With m25p80 and mtchar, the
> transfer buffer can be quite large (up to 4 MiB in my case), and this can be
> triggered from userspace.

That's readily fixable for DMA capable drivers, we can just repeatedly
transfer the same page (or whatever).  PIO drivers have big problems
with such large transfers anyway but could also easily have the transfer
segmented for them in a similar way.  Once we do these things we ought
to be able to avoid having to free the buffer on idle (though a memory
pressure notifier is probably polite) which helps too.  What's there
currently is very much a first pass implementation so things work,
there's plenty of room for optimisation.

> Alternatively, to avoid the memory allocation, you could zero rx_buf,
> and use rx_buf for both tx and rx? That may break some DMA setups,
> though.

As you say it's not clever for DMA and means you have to do the memset()
each time you use the buffer.

> Concluding, for PIO mode, I'm still in favor of using

>     data = tx_buf ? *tx_buf++ : DUMMY_DATA;

> in the SPI master driver itself.

With the ternery operator for legibility of course.

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux