[U-Boot] [PATCH 1/2] common: make bouncebuf work for non-DMA transfers

Goldschmidt Simon sgoldschmidt at de.pepperl-fuchs.com
Thu Nov 16 10:09:17 UTC 2017


Simon Goldschmidt wrote:
>Marek Vasut wrote:
>> So what alignment problems do you observe ? If you copy using the CPU
>> only, why do you need the bounce buffer at all ? I don't quite get it.
> 
> Sorry for not explaining it good enough:
> I don't observe any alignment problems. mach-socfpga can do unaligned
> accesses as well. This driver does CPU based copy, but since it transfers
> words, not bytes, I guess on other platforms, the CPU might fail when trying
> to read a word from an unaligned pointer.
>
> Vignesh added this about a year ago and from that commit message, it
> seems like he was observing alignment errors on his TI platform.
> Also, those commits have a reviewed-by tag from you and Jagan.
>
> For me, reverting these patches would be OK as well, but I guess Vinesh's
> TI platform kind of needs them?

So to clarify it again, the cadence_spi driver has to transfer 32-bit
words to/from the hardware and the driver uses 'readsl' and 'writesl'
to do this. Now if the source/destination buffer is not aligned, this
results in an error on platforms that do not support unaligned access.

We have three options here:
a) fix all call stacks calling dm_spi_ops->xfer to use aligned buffers
   (which could be hard when looking at 'sf read')
b) fix the driver by doing malloc + memcpy or loading byte by byte from
   ram
c) add framework functions doing malloc + memcpy (which is nearly the
   same as bouncebuf)

This 32-bit spi transfer mode does not seem to be used too often, all
other drivers I looked at are transferring byte by byte and thus can
not be used as an example.

Additionally, the TI platform Vignesh used obviously does not support
unaligned access (which is why he added using bouncebuf here although
no dma is used) while mach-socfpga supports unaligned accesses by
default.

So given my explanation above, what's the preferred way to fix this?

I thought a framework solution would be better, which is why I modified
bouncebuf to work with this, but as cadence_qspi is the only driver
using bouncebuf in this fashion for now, I'm open for suggestions.

I need this driver fixed, so whatever way will be accepted is fine by
me, I guess. Just let me know.

Simon


More information about the U-Boot mailing list