From owner-p4-projects@FreeBSD.ORG Wed Apr 4 17:13:53 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 040A61065670; Wed, 4 Apr 2012 17:13:53 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BACCA106564A for ; Wed, 4 Apr 2012 17:13:52 +0000 (UTC) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id 8907B8FC0C for ; Wed, 4 Apr 2012 17:13:52 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id q34HDqni077697 for ; Wed, 4 Apr 2012 17:13:52 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id q34HDqOa077694 for perforce@freebsd.org; Wed, 4 Apr 2012 17:13:52 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Wed, 4 Apr 2012 17:13:52 GMT Message-Id: <201204041713.q34HDqOa077694@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 209073 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2012 17:13:53 -0000 http://p4web.freebsd.org/@@209073?ac=10 Change 209073 by rwatson@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"); }