#1580 closed enhancement (fixed)

spi-sd-card: use bigger chunks and yield processor while waiting for read data

Reported by: Arnout Vandecappelle Owned by: Sebastian Huber
Priority: normal Milestone: 4.11
Component: unspecified Version: 4.11
Severity: minor Keywords:
Cc: joel.sherrill@… Blocked By:


The function sd_card_read() polls the SPI bus until the data is available. On various SD cards, I've seen latencies between 5 and 200 bytes.

First of all, reading in chunks of 18 bytes is not efficient since the DMA of the SPI remains under-used.

Second, while we wait, other tasks should be allowed to take over.

Attached patch uses bigger chunks while waiting for the read data and yields the processor. It depends on attachment 792 to bug 1567.

Note that sleeping like in attachment 810 to bug 1579 is not efficient since the waiting time tends to be far below 1 tick. Sleeping reduces the read throughput significantly.

Attachments (1)

0001-c-src-libchip-i2c-spi-sd-card.c-do-read-polling-in-b.patch (4.3 KB) - added by Arnout Vandecappelle on Jun 21, 2010 at 3:55:17 PM.
spi-sd-card.c: do read polling in bigger blocks and yield the CPU

Download all attachments as: .zip

Change History (5)

Changed on Jun 21, 2010 at 3:55:17 PM by Arnout Vandecappelle

spi-sd-card.c: do read polling in bigger blocks and yield the CPU

comment:1 Changed on Jun 22, 2010 at 10:38:09 AM by Sebastian Huber

Resolution: fixed
Status: newclosed

comment:2 Changed on Jun 22, 2010 at 10:48:27 AM by Sebastian Huber

Replying to comment:4:

Replying to comment:3:

I think its save to assume that the tick is around one micro second or more.

Surely you mean millisecond?

Oh, yes. I meant milli seconds.

comment:3 Changed on Nov 24, 2014 at 6:58:28 PM by Gedare Bloom

Version: HEAD4.11

Replace Version=HEAD with Version=4.11 for the tickets with Milestone >= 4.11

comment:4 Changed on Oct 10, 2017 at 6:35:44 AM by Sebastian Huber

Component: miscunspecified
Note: See TracTickets for help on using tickets.