PERFORCE change 209412 for review
Robert Watson
rwatson at FreeBSD.org
Wed Apr 11 12:19:45 UTC 2012
http://p4web.freebsd.org/@@209412?ac=10
Change 209412 by rwatson at rwatson_svr_ctsrd_mipsbuild on 2012/04/11 12:19:09
Refinements to the Altera SD Card IP core device driver:
1. Make ignoring CRC errors on read configurable, although currently
only with the debugger, not with a sysctl. Spurious CRC errors
still seem to be generated with moderate frequency, so we
continue to ignore them by default.
2. Use 16-bit fetch and store operations when reading and writing
from larger buffers, especially the RXTX buffer, on the IP core.
Although there appears to be VHDL to support 8-bit fetches and
stores over Avalon, they don't appear to work. This introduces
an alignment requirement on buffers passed down the storage
stack, due to bus_space assuming that alignment of the I/O target
implies similar alignment to the I/O source. Assertion added to
check on each I/O that this is true -- thus far it always has
been with UFS.
With these changes, read-write mounts of UFS on the Terasic DE-4 SD
Card slot appear reliable from FreeBSD/BERI.
Affected files ...
.. //depot/projects/ctsrd/beribsd/src/sys/dev/altera/sdcard/altera_sdcard_io.c#11 edit
Differences ...
==== //depot/projects/ctsrd/beribsd/src/sys/dev/altera/sdcard/altera_sdcard_io.c#11 (text+ko) ====
@@ -53,6 +53,8 @@
#include <dev/altera/sdcard/altera_sdcard.h>
+int altera_sdcard_ignore_crc_errors = 1;
+
/*
* Low-level I/O routines for the Altera SD Card University IP Core driver.
*
@@ -146,8 +148,10 @@
* XXXRW: Treating this as an array of bytes, so no byte swapping --
* is that a safe assumption?
*/
- bus_read_region_1(sc->as_res, ALTERA_SDCARD_OFF_CSD,
- sc->as_csd.csd_data, sizeof(sc->as_csd));
+ KASSERT(((uintptr_t)&sc->as_csd.csd_data) % 2 == 0,
+ ("%s: CSD buffer unaligned", __func__));
+ bus_read_region_2(sc->as_res, ALTERA_SDCARD_OFF_CSD,
+ (uint16_t *)sc->as_csd.csd_data, sizeof(sc->as_csd) / 2);
/*
* Interpret the loaded CSD, extracting certain fields and copying
@@ -214,11 +218,13 @@
size_t len)
{
- KASSERT(len <= ALTERA_SDCARD_SECTORSIZE,
+ KASSERT((uintptr_t)data % 2 == 0,
+ ("%s: unaligned data %p", __func__, data));
+ KASSERT((len <= ALTERA_SDCARD_SECTORSIZE) && (len % 2 == 0),
("%s: invalid length %ju", __func__, len));
- bus_read_region_1(sc->as_res, ALTERA_SDCARD_OFF_RXTX_BUFFER, data,
- len);
+ bus_read_region_2(sc->as_res, ALTERA_SDCARD_OFF_RXTX_BUFFER,
+ (uint16_t *)data, len / 2);
}
static void
@@ -226,11 +232,13 @@
size_t len)
{
- KASSERT(len <= ALTERA_SDCARD_SECTORSIZE,
+ KASSERT((uintptr_t)data % 2 == 0,
+ ("%s: unaligned data %p", __func__, data));
+ KASSERT((len <= ALTERA_SDCARD_SECTORSIZE) && (len % 2 == 0),
("%s: invalid length %ju", __func__, len));
- bus_write_region_1(sc->as_res, ALTERA_SDCARD_OFF_RXTX_BUFFER, data,
- len);
+ bus_write_region_2(sc->as_res, ALTERA_SDCARD_OFF_RXTX_BUFFER,
+ (uint16_t *)data, len / 2);
}
static void
@@ -303,14 +311,16 @@
* quirks handled in the process:
*
* 1. ALTERA_SDCARD_ASR_CMDDATAERROR is ignored for BIO_WRITE.
- * 2. ALTERA_SDCARD_RR1_COMMANDCRCFAILED is ignored for BIO_READ.
+ * 2. ALTERA_SDCARD_RR1_COMMANDCRCFAILED is optionally ignored for
+ * BIO_READ.
*/
error = 0;
rr1 = altera_sdcard_read_rr1(sc);
switch (bp->bio_cmd) {
case BIO_READ:
mask = ALTERA_SDCARD_RR1_ERRORMASK;
- mask &= ~ALTERA_SDCARD_RR1_COMMANDCRCFAILED;
+ if (altera_sdcard_ignore_crc_errors)
+ mask &= ~ALTERA_SDCARD_RR1_COMMANDCRCFAILED;
if (asr & ALTERA_SDCARD_ASR_CMDTIMEOUT)
error = EIO;
else if ((asr & ALTERA_SDCARD_ASR_CMDDATAERROR) &&
More information about the p4-projects
mailing list