PERFORCE change 209073 for review
Robert Watson
rwatson at FreeBSD.org
Wed Apr 4 17:13:53 UTC 2012
http://p4web.freebsd.org/@@209073?ac=10
Change 209073 by rwatson at rwatson_svr_ctsrd_mipsbuild on 2012/04/04 17:13:10
Fix two bugs in the Altera SD Card IP Core:
1. More serious -- don't perform sleeping memory allocations while
holding mutexes. Discovered by turning on WITNESS.
2. Less serious -- Simply print SD Card size in MB, don't try and
do a GB calculation, as floor(MB) is less worrying than
floor(GB) for a (very nearly) 2GB SD Card.
Affected files ...
.. //depot/projects/ctsrd/beribsd/src/sys/dev/altera/sdcard/altera_sdcard_disk.c#4 edit
Differences ...
==== //depot/projects/ctsrd/beribsd/src/sys/dev/altera/sdcard/altera_sdcard_disk.c#4 (text+ko) ====
@@ -117,7 +117,6 @@
{
struct disk *disk;
uint64_t size;
- char scale;
ALTERA_SDCARD_LOCK_ASSERT(sc);
@@ -131,7 +130,6 @@
*/
ALTERA_SDCARD_UNLOCK(sc);
disk = disk_alloc();
- ALTERA_SDCARD_LOCK(sc);
disk->d_drv1 = sc;
disk->d_name = "altera_sdcard";
disk->d_unit = sc->as_unit;
@@ -143,24 +141,14 @@
disk->d_maxsize = ALTERA_SDCARD_SECTORSIZE;
sc->as_disk = disk;
disk_create(disk, DISK_VERSION);
+ ALTERA_SDCARD_LOCK(sc);
/*
* Print a pretty-ish card insertion string. We could stand to
* decorate this further, e.g., with card vendor information.
*/
- size = sc->as_mediasize;
- if (size > 1024*1024*1024) {
- scale = 'G';
- size /= 1024*1024*1024;
- } else if (size > 1024*1024) {
- scale = 'M';
- size /= 1024*1024;
- } else {
- scale = 'K';
- size /= 1024;
- }
- device_printf(sc->as_dev, "%ju%c SD Card inserted\n", (uintmax_t)size,
- scale);
+ size = sc->as_mediasize / (1000 * 1000);
+ device_printf(sc->as_dev, "%juM SD Card inserted\n", (uintmax_t)size);
}
void
@@ -192,4 +180,5 @@
sc->as_currentbio = NULL;
}
bioq_flush(&sc->as_bioq, NULL, ENXIO);
+ device_printf(sc->as_dev, "SD Card removed\n");
}
More information about the p4-projects
mailing list