change log for rtems (2010-06-22)
rtems-vc at rtems.org
rtems-vc at rtems.org
Tue Jun 22 09:11:58 UTC 2010
*sh*:
2010-06-22 Arnout Vandecappelle <arnout at mind.be>
PR 1567/misc
* libchip/i2c/spi-sd-card.h, libchip/i2c/spi-sd-card.c: Fixed
timeouts.
M 1.525 c/src/ChangeLog
M 1.6 c/src/libchip/i2c/spi-sd-card.h
M 1.20 c/src/libchip/i2c/spi-sd-card.c
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
@@ -1,3 +1,9 @@
+2010-06-22 Arnout Vandecappelle <arnout at mind.be>
+
+ PR 1567/misc
+ * libchip/i2c/spi-sd-card.h, libchip/i2c/spi-sd-card.c: Fixed
+ timeouts.
+
2010-06-21 Arnout Vandecappelle <arnout at mind.be>
PR 1576/misc
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
@@ -52,7 +52,8 @@
SD_CARD_IDLE_TOKEN \
}
-#define SD_CARD_N_AC_MAX_DEFAULT 8
+/* Default speed = 400kbps, default timeout = 100ms, n_ac_max is in bytes */
+#define SD_CARD_N_AC_MAX_DEFAULT 5000
typedef struct {
const char *device_name;
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
@@ -301,9 +301,16 @@
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);
+ uint32_t ac_100ms = transfer_speed / 80;
uint32_t n = SD_CARD_CSD_GET_NSAC( csd) * 100;
- ac = (ac * transfer_speed) / 8000000000ULL;
- return n + (uint32_t) ac;
+ /* 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;
}
/** @} */
@@ -362,6 +369,10 @@
int rv = 0;
int r = 0;
int n = 2;
+ /* 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;
while (e->busy) {
/* Query busy tokens */
rv = sd_card_query( e, e->response, n);
@@ -374,6 +385,10 @@
return 0;
}
}
+ retries -= n;
+ if (retries <= 0) {
+ return -RTEMS_TIMEOUT;
+ }
n = SD_CARD_COMMAND_SIZE;
if (e->schedule_if_busy) {
@@ -957,6 +972,9 @@
capacity = (c_size + 1) * 512 * 1024;
read_block_size = 512;
write_block_size = 512;
+
+ /* Timeout is fixed at 100ms in CSD Version 2.0 */
+ e->n_ac_max = transfer_speed / 80;
} else {
RTEMS_DO_CLEANUP_SC( RTEMS_IO_ERROR, sc, sd_card_driver_init_cleanup, "Unexpected CSD Structure number");
}
@@ -967,6 +985,7 @@
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));
+ RTEMS_SYSLOG( "Access time [N] : %" PRIu32 "\n", SD_CARD_CSD_GET_NSAC( block)*100);
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);
@@ -1206,14 +1225,14 @@
case RTEMS_BLKDEV_REQ_WRITE:
return sd_card_disk_block_write( e, r);
default:
- errno = EINVAL;
+ errno = EINVAL;
return -1;
}
} else if (req == RTEMS_BLKIO_CAPABILITIES) {
*(uint32_t *) arg = RTEMS_BLKDEV_CAP_MULTISECTOR_CONT;
return 0;
} else {
- errno = EINVAL;
+ errno = EINVAL;
return -1;
}
}
*sh*:
2010-06-22 Arnout Vandecappelle <arnout at mind.be>
PR 1579/misc
* libchip/i2c/spi-sd-card.c: Gradually increasing sleep times when
waiting for write to finish.
M 1.526 c/src/ChangeLog
M 1.21 c/src/libchip/i2c/spi-sd-card.c
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
@@ -1,5 +1,11 @@
2010-06-22 Arnout Vandecappelle <arnout at mind.be>
+ 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 at mind.be>
+
PR 1567/misc
* libchip/i2c/spi-sd-card.h, libchip/i2c/spi-sd-card.c: Fixed
timeouts.
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
@@ -373,6 +373,10 @@
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;
+ /* 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;
while (e->busy) {
/* Query busy tokens */
rv = sd_card_query( e, e->response, n);
@@ -389,11 +393,16 @@
if (retries <= 0) {
return -RTEMS_TIMEOUT;
}
- n = SD_CARD_COMMAND_SIZE;
if (e->schedule_if_busy) {
- /* Invoke the scheduler */
- rtems_task_wake_after( RTEMS_YIELD_PROCESSOR);
+ 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;
}
}
return 0;
--
Generated by Deluxe Loginfo [http://www.codewiz.org/projects/index.html#loginfo] 2.122 by Bernardo Innocenti <bernie at develer.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/vc/attachments/20100622/7af683b1/attachment.html>
More information about the vc
mailing list