<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>change log for rtems (2010-06-22)</title>
</head>
<body text='#000000' bgcolor='#ffffff'>
<a name='cs1'></a>
<table border='0' cellspacing='0' cellpadding='5' width='100%' bgcolor='#eeeeee'>
<tr><td colspan='3' bgcolor='#dddddd'>
<font color='#bb2222'><strong>sh</strong></font>
</td></tr>
<tr><td colspan='3' bgcolor='#dddddd'><pre>2010-06-22 Arnout Vandecappelle <arnout@mind.be>
PR 1567/misc
* libchip/i2c/spi-sd-card.h, libchip/i2c/spi-sd-card.c: Fixed
timeouts.
</pre></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/c/src/ChangeLog.diff?r1=text&tr1=1.524&r2=text&tr2=1.525&diff_format=h">M</a></td><td width='1%'>1.525</td><td width='100%'>c/src/ChangeLog</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/c/src/libchip/i2c/spi-sd-card.h.diff?r1=text&tr1=1.5&r2=text&tr2=1.6&diff_format=h">M</a></td><td width='1%'>1.6</td><td width='100%'>c/src/libchip/i2c/spi-sd-card.h</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/c/src/libchip/i2c/spi-sd-card.c.diff?r1=text&tr1=1.19&r2=text&tr2=1.20&diff_format=h">M</a></td><td width='1%'>1.20</td><td width='100%'>c/src/libchip/i2c/spi-sd-card.c</td></tr>
</table>
<pre>
<font color='#006600'>diff -u rtems/c/src/ChangeLog:1.524 rtems/c/src/ChangeLog:1.525
--- rtems/c/src/ChangeLog:1.524 Mon Jun 21 10:25:04 2010
+++ rtems/c/src/ChangeLog Tue Jun 22 03:37:26 2010
</font><font color='#997700'>@@ -1,3 +1,9 @@
</font><font color='#000088'>+2010-06-22 Arnout Vandecappelle <arnout@mind.be>
+
+ PR 1567/misc
+ * libchip/i2c/spi-sd-card.h, libchip/i2c/spi-sd-card.c: Fixed
+ timeouts.
+
</font> 2010-06-21 Arnout Vandecappelle <arnout@mind.be>
PR 1576/misc
<font color='#006600'>diff -u rtems/c/src/libchip/i2c/spi-sd-card.h:1.5 rtems/c/src/libchip/i2c/spi-sd-card.h:1.6
--- rtems/c/src/libchip/i2c/spi-sd-card.h:1.5 Sun Nov 29 21:42:53 2009
+++ rtems/c/src/libchip/i2c/spi-sd-card.h Tue Jun 22 03:37:26 2010
</font><font color='#997700'>@@ -52,7 +52,8 @@
</font> SD_CARD_IDLE_TOKEN \
}
<font color='#880000'>-#define SD_CARD_N_AC_MAX_DEFAULT 8
</font><font color='#000088'>+/* Default speed = 400kbps, default timeout = 100ms, n_ac_max is in bytes */
+#define SD_CARD_N_AC_MAX_DEFAULT 5000
</font>
typedef struct {
const char *device_name;
<font color='#006600'>diff -u rtems/c/src/libchip/i2c/spi-sd-card.c:1.19 rtems/c/src/libchip/i2c/spi-sd-card.c:1.20
--- rtems/c/src/libchip/i2c/spi-sd-card.c:1.19 Mon Jun 21 10:25:04 2010
+++ rtems/c/src/libchip/i2c/spi-sd-card.c Tue Jun 22 03:37:26 2010
</font><font color='#997700'>@@ -301,9 +301,16 @@
</font> static inline uint32_t sd_card_max_access_time( const uint8_t *csd, uint32_t transfer_speed)
{
uint64_t ac = sd_card_access_time( csd);
<font color='#000088'>+ uint32_t ac_100ms = transfer_speed / 80;
</font> uint32_t n = SD_CARD_CSD_GET_NSAC( csd) * 100;
<font color='#880000'>- ac = (ac * transfer_speed) / 8000000000ULL;
- return n + (uint32_t) ac;
</font><font color='#000088'>+ /* ac is in ns, transfer_speed in bps, max_access_time in bytes.
+ max_access_time is 100 times typical access time (taac+nsac) */
+ ac = ac * transfer_speed / 80000000;
+ ac = ac + 100*n;
+ if ((uint32_t)ac > ac_100ms)
+ return ac_100ms;
+ else
+ return (uint32_t)ac;
</font> }
/** @} */
<font color='#997700'>@@ -362,6 +369,10 @@
</font> int rv = 0;
int r = 0;
int n = 2;
<font color='#000088'>+ /* For writes, the timeout is 2.5 times that of reads; since we
+ don't know if it is a write or read, assume write.
+ FIXME should actually look at R2W_FACTOR for non-HC cards. */
+ int retries = e->n_ac_max * 25 / 10;
</font> while (e->busy) {
/* Query busy tokens */
rv = sd_card_query( e, e->response, n);
<font color='#997700'>@@ -374,6 +385,10 @@
</font> return 0;
}
}
<font color='#000088'>+ retries -= n;
+ if (retries <= 0) {
+ return -RTEMS_TIMEOUT;
+ }
</font> n = SD_CARD_COMMAND_SIZE;
if (e->schedule_if_busy) {
<font color='#997700'>@@ -957,6 +972,9 @@
</font> capacity = (c_size + 1) * 512 * 1024;
read_block_size = 512;
write_block_size = 512;
<font color='#000088'>+
+ /* Timeout is fixed at 100ms in CSD Version 2.0 */
+ e->n_ac_max = transfer_speed / 80;
</font> } else {
RTEMS_DO_CLEANUP_SC( RTEMS_IO_ERROR, sc, sd_card_driver_init_cleanup, "Unexpected CSD Structure number");
}
<font color='#997700'>@@ -967,6 +985,7 @@
</font> RTEMS_SYSLOG( "CSD structure : %" PRIu8 "\n", SD_CARD_CSD_GET_CSD_STRUCTURE( block));
RTEMS_SYSLOG( "Spec version : %" PRIu8 "\n", SD_CARD_CSD_GET_SPEC_VERS( block));
RTEMS_SYSLOG( "Access time [ns] : %" PRIu32 "\n", sd_card_access_time( block));
<font color='#000088'>+ RTEMS_SYSLOG( "Access time [N] : %" PRIu32 "\n", SD_CARD_CSD_GET_NSAC( block)*100);
</font> RTEMS_SYSLOG( "Max access time [N] : %" PRIu32 "\n", e->n_ac_max);
RTEMS_SYSLOG( "Max read block size [B] : %" PRIu32 "\n", read_block_size);
RTEMS_SYSLOG( "Max write block size [B] : %" PRIu32 "\n", write_block_size);
<font color='#997700'>@@ -1206,14 +1225,14 @@
</font> case RTEMS_BLKDEV_REQ_WRITE:
return sd_card_disk_block_write( e, r);
default:
<font color='#880000'>- errno = EINVAL;
</font><font color='#000088'>+ errno = EINVAL;
</font> return -1;
}
} else if (req == RTEMS_BLKIO_CAPABILITIES) {
*(uint32_t *) arg = RTEMS_BLKDEV_CAP_MULTISECTOR_CONT;
return 0;
} else {
<font color='#880000'>- errno = EINVAL;
</font><font color='#000088'>+ errno = EINVAL;
</font> return -1;
}
}
</pre>
<p> </p>
<a name='cs2'></a>
<table border='0' cellspacing='0' cellpadding='5' width='100%' bgcolor='#eeeeee'>
<tr><td colspan='3' bgcolor='#dddddd'>
<font color='#bb2222'><strong>sh</strong></font>
</td></tr>
<tr><td colspan='3' bgcolor='#dddddd'><pre>2010-06-22 Arnout Vandecappelle <arnout@mind.be>
PR 1579/misc
* libchip/i2c/spi-sd-card.c: Gradually increasing sleep times when
waiting for write to finish.
</pre></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/c/src/ChangeLog.diff?r1=text&tr1=1.525&r2=text&tr2=1.526&diff_format=h">M</a></td><td width='1%'>1.526</td><td width='100%'>c/src/ChangeLog</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/c/src/libchip/i2c/spi-sd-card.c.diff?r1=text&tr1=1.20&r2=text&tr2=1.21&diff_format=h">M</a></td><td width='1%'>1.21</td><td width='100%'>c/src/libchip/i2c/spi-sd-card.c</td></tr>
</table>
<pre>
<font color='#006600'>diff -u rtems/c/src/ChangeLog:1.525 rtems/c/src/ChangeLog:1.526
--- rtems/c/src/ChangeLog:1.525 Tue Jun 22 03:37:26 2010
+++ rtems/c/src/ChangeLog Tue Jun 22 03:41:08 2010
</font><font color='#997700'>@@ -1,5 +1,11 @@
</font> 2010-06-22 Arnout Vandecappelle <arnout@mind.be>
<font color='#000088'>+ PR 1579/misc
+ * libchip/i2c/spi-sd-card.c: Gradually increasing sleep times when
+ waiting for write to finish.
+
+2010-06-22 Arnout Vandecappelle <arnout@mind.be>
+
</font> PR 1567/misc
* libchip/i2c/spi-sd-card.h, libchip/i2c/spi-sd-card.c: Fixed
timeouts.
<font color='#006600'>diff -u rtems/c/src/libchip/i2c/spi-sd-card.c:1.20 rtems/c/src/libchip/i2c/spi-sd-card.c:1.21
--- rtems/c/src/libchip/i2c/spi-sd-card.c:1.20 Tue Jun 22 03:37:26 2010
+++ rtems/c/src/libchip/i2c/spi-sd-card.c Tue Jun 22 03:41:08 2010
</font><font color='#997700'>@@ -373,6 +373,10 @@
</font> don't know if it is a write or read, assume write.
FIXME should actually look at R2W_FACTOR for non-HC cards. */
int retries = e->n_ac_max * 25 / 10;
<font color='#000088'>+ /* n_ac_max/100 is supposed to be the average waiting time. To
+ approximate this, we start with waiting n_ac_max/250 and
+ gradually increase the waiting time. */
+ int wait_time_bytes = (retries + 149) / 150;
</font> while (e->busy) {
/* Query busy tokens */
rv = sd_card_query( e, e->response, n);
<font color='#997700'>@@ -389,11 +393,16 @@
</font> if (retries <= 0) {
return -RTEMS_TIMEOUT;
}
<font color='#880000'>- n = SD_CARD_COMMAND_SIZE;
</font>
if (e->schedule_if_busy) {
<font color='#880000'>- /* Invoke the scheduler */
- rtems_task_wake_after( RTEMS_YIELD_PROCESSOR);
</font><font color='#000088'>+ uint64_t wait_time_us = wait_time_bytes;
+ wait_time_us *= 8000000;
+ wait_time_us /= e->transfer_mode.baudrate;
+ rtems_task_wake_after( RTEMS_MICROSECONDS_TO_TICKS(wait_time_us));
+ retries -= wait_time_bytes;
+ wait_time_bytes = wait_time_bytes * 15 / 10;
+ } else {
+ n = SD_CARD_COMMAND_SIZE;
</font> }
}
return 0;
</pre>
<p> </p>
<p>--<br />
<small>Generated by <a href="http://www.codewiz.org/projects/index.html#loginfo">Deluxe Loginfo</a> 2.122 by Bernardo Innocenti <bernie@develer.com></small></p>
</body>
</html>