From nobody@FreeBSD.org  Fri Jul  9 16:54:16 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 6ED08106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  9 Jul 2010 16:54:16 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 5E8A68FC0A
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  9 Jul 2010 16:54:16 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o69GsFm4032018
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 9 Jul 2010 16:54:15 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o69GsF1n032013;
	Fri, 9 Jul 2010 16:54:15 GMT
	(envelope-from nobody)
Message-Id: <201007091654.o69GsF1n032013@www.freebsd.org>
Date: Fri, 9 Jul 2010 16:54:15 GMT
From: Greg Ansley <gja@ansley.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: MMC timeout too short durring enumeration of cards.
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         148474
>Category:       arm
>Synopsis:       MMC timeout too short durring enumeration of cards.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-arm
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jul 09 17:00:14 UTC 2010
>Closed-Date:    Mon Aug 16 10:30:24 MDT 2010
>Last-Modified:  Mon Aug 16 10:30:24 MDT 2010
>Originator:     Greg Ansley
>Release:        8-stabe & 9-current
>Organization:
Ansley & Associates, Inc.
>Environment:
>Description:
Large SD cards take much longer to come out of the power-up state than earlier smaller cards.

Current command loop terminates after 100 attempts waiting for a card to become ready.  A 1G card currently takes 241 iterations to become ready on a 400Mhz AT91SAM9G20. A 8G card was took 721.

SD card spec does not specify a maximum wait time.

The patch bumps the loop count to for 100 to 5000. Note that this does not affect the no-card or error condition timings.
>How-To-Repeat:
Boot system with SD card present. Large cards will not be found. Small cards work fine.
>Fix:


Patch attached with submission follows:

Index: mmc.c
===================================================================
RCS file: /usr/home/ncvs/src/sys/dev/mmc/mmc.c,v
retrieving revision 1.38
diff -r1.38 mmc.c
451c451
< 	for (i = 0; i < 100; i++) {
---
> 	for (i = 0; i < 5000; i++) {
478c478
< 	for (i = 0; i < 100; i++) {
---
> 	for (i = 0; i < 5000; i++) {


>Release-Note:
>Audit-Trail:

From: "M. Warner Losh" <imp@bsdimp.com>
To: gja@ansley.com
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: arm/148474: MMC timeout too short durring enumeration of cards.
Date: Fri, 09 Jul 2010 14:19:24 -0600 (MDT)

 In message: <201007091654.o69GsF1n032013@www.freebsd.org>
             Greg Ansley <gja@ansley.com> writes:
 : Large SD cards take much longer to come out of the power-up state than earlier smaller cards.
 
 This happens to be exactly opposite what I've observed...  Cards up to
 4GB in my AT91RM9200 are ready right away.  Older, 16MB and 32MB cards
 have taken up to 10 iterations to become ready.
 
 : Current command loop terminates after 100 attempts waiting for a
 : card to become ready.  A 1G card currently takes 241 iterations to
 : become ready on a 400Mhz AT91SAM9G20. A 8G card was took 721. 
 
 It really took 2.4s for the 1G card and 7.21s for the 8G card to
 become ready?  Are you sure?  Are you sure there's not some other
 timing bug going on that causes mms_delay_ms(10) to return much more
 quickly than 10ms?
 
 Also, which tree are you booting that has AT91SAM9G20 support, that's
 not in main yet :)  I'll let that slide.
 
 Your patch causes us to wait for up to 50s for this to happen.  That
 seems excessively long to me, and doesn't match my experience with
 these devices, even the ultra-uber-crappy consumer cards.
 
 Warner
 
 
 : SD card spec does not specify a maximum wait time.
 : 
 : The patch bumps the loop count to for 100 to 5000. Note that this does not affect the no-card or error condition timings.
 : >How-To-Repeat:
 : Boot system with SD card present. Large cards will not be found. Small cards work fine.
 : >Fix:
 : 
 : 
 : Patch attached with submission follows:
 : 
 : Index: mmc.c
 : ===================================================================
 : RCS file: /usr/home/ncvs/src/sys/dev/mmc/mmc.c,v
 : retrieving revision 1.38
 : diff -r1.38 mmc.c
 : 451c451
 : < 	for (i = 0; i < 100; i++) {
 : ---
 : > 	for (i = 0; i < 5000; i++) {
 : 478c478
 : < 	for (i = 0; i < 100; i++) {
 : ---
 : > 	for (i = 0; i < 5000; i++) {
 : 
 : 
 : >Release-Note:
 : >Audit-Trail:
 : >Unformatted:
 : _______________________________________________
 : freebsd-arm@freebsd.org mailing list
 : http://lists.freebsd.org/mailman/listinfo/freebsd-arm
 : To unsubscribe, send any mail to "freebsd-arm-unsubscribe@freebsd.org"
 : 
 : 

From: Greg Ansley <gja@ansley.com>
To: bug-followup@FreeBSD.org, gja@ansley.com
Cc:  
Subject: Re: arm/148474: MMC timeout too short durring enumeration of cards.
Date: Sat, 10 Jul 2010 07:46:12 -0400

 PR is bogus and can be closed.  Problem went away with refresh of source 
 tree. Sorry.
 
 Greg Ansley
State-Changed-From-To: open->closed 
State-Changed-By: imp 
State-Changed-When: Mon Aug 16 10:29:49 MDT 2010 
State-Changed-Why:  
Turns out this was caused by a timing bug (or other heisenbug).  Closing. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=148474 
>Unformatted:
