* [U-Boot] [PATCH 1/5] spi/ich.c: Fix a bug of reading from a non-64 bytes aligned address
@ 2014-10-23 13:36 Bin Meng
2014-10-24 4:13 ` Simon Glass
0 siblings, 1 reply; 2+ messages in thread
From: Bin Meng @ 2014-10-23 13:36 UTC (permalink / raw)
To: u-boot
The ich spi controller driver spi_xfer() tries to align reading
address to 64 bytes when doing spi data in, which causes a bug of
either infinite loop or a huge size memcpy().
Actually the ich spi controller does not have such requirement of
64 bytes alignment when reading data from spi slave devices.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---
drivers/spi/ich.c | 17 ++---------------
1 file changed, 2 insertions(+), 15 deletions(-)
diff --git a/drivers/spi/ich.c b/drivers/spi/ich.c
index f5c6f3e..c4d3a29 100644
--- a/drivers/spi/ich.c
+++ b/drivers/spi/ich.c
@@ -483,8 +483,6 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
struct spi_trans *trans = &ich->trans;
unsigned type = flags & (SPI_XFER_BEGIN | SPI_XFER_END);
int using_cmd = 0;
- /* Align read transactions to 64-byte boundaries */
- char buff[ctlr.databytes];
/* Ee don't support writing partial bytes. */
if (bitlen % 8) {
@@ -632,14 +630,9 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
*/
while (trans->bytesout || trans->bytesin) {
uint32_t data_length;
- uint32_t aligned_offset;
- uint32_t diff;
-
- aligned_offset = trans->offset & ~(ctlr.databytes - 1);
- diff = trans->offset - aligned_offset;
/* SPI addresses are 24 bit only */
- ich_writel(aligned_offset & 0x00FFFFFF, ctlr.addr);
+ ich_writel(trans->offset & 0x00FFFFFF, ctlr.addr);
if (trans->bytesout)
data_length = min(trans->bytesout, ctlr.databytes);
@@ -673,13 +666,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
}
if (trans->bytesin) {
- if (diff) {
- data_length -= diff;
- read_reg(ctlr.data, buff, ctlr.databytes);
- memcpy(trans->in, buff + diff, data_length);
- } else {
- read_reg(ctlr.data, trans->in, data_length);
- }
+ read_reg(ctlr.data, trans->in, data_length);
spi_use_in(trans, data_length);
if (with_address)
trans->offset += data_length;
--
1.8.2.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [U-Boot] [PATCH 1/5] spi/ich.c: Fix a bug of reading from a non-64 bytes aligned address
2014-10-23 13:36 [U-Boot] [PATCH 1/5] spi/ich.c: Fix a bug of reading from a non-64 bytes aligned address Bin Meng
@ 2014-10-24 4:13 ` Simon Glass
0 siblings, 0 replies; 2+ messages in thread
From: Simon Glass @ 2014-10-24 4:13 UTC (permalink / raw)
To: u-boot
On 23 October 2014 07:36, Bin Meng <bmeng.cn@gmail.com> wrote:
> The ich spi controller driver spi_xfer() tries to align reading
> address to 64 bytes when doing spi data in, which causes a bug of
> either infinite loop or a huge size memcpy().
>
> Actually the ich spi controller does not have such requirement of
> 64 bytes alignment when reading data from spi slave devices.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> ---
> drivers/spi/ich.c | 17 ++---------------
> 1 file changed, 2 insertions(+), 15 deletions(-)
Acked-by: Simon Glass <sjg@chromium.org>
Tested on link
Tested-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-10-24 4:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-23 13:36 [U-Boot] [PATCH 1/5] spi/ich.c: Fix a bug of reading from a non-64 bytes aligned address Bin Meng
2014-10-24 4:13 ` Simon Glass
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.